Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "encoding/json"
- "fmt"
- "log"
- "os"
- "os/signal"
- "syscall"
- "time"
- "github.com/riobard/go-shadowsocks2/core"
- )
- var config struct {
- Verbose bool
- UDPTimeout time.Duration
- }
- func logf(f string, v ...interface{}) {
- if config.Verbose {
- log.Printf(f, v...)
- }
- }
- var settings struct {
- Server string `json:"server"`
- ServerPort int `json:"server_port"`
- LocalPort int `json:"local_port"`
- Password string `json:"password"`
- Method string `json:"method"`
- Timeout int `json:"timeout"`
- }
- func main() {
- configFile, err := os.Open("config.json")
- defer configFile.Close()
- if err != nil {
- log.Fatal(err)
- }
- jsonParser := json.NewDecoder(configFile)
- if err = jsonParser.Decode(&settings); err != nil {
- log.Fatal("parsing config file", err.Error())
- }
- server := fmt.Sprintf("%s:%d", settings.Server, settings.ServerPort)
- local := fmt.Sprintf("127.0.0.1:%d", settings.LocalPort)
- var key []byte
- ciph, err := core.PickCipher(settings.Method, key, settings.Password)
- go socksLocal(local, server, ciph)
- sigCh := make(chan os.Signal, 1)
- signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
- <-sigCh
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement