1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package main
import (
"flag"
"io"
"log"
"net"
"os"
"0xacab.org/leap/obfsvpn/client"
)
func main() {
// Setup logging.
logger := log.New(os.Stderr, "", log.LstdFlags)
debug := log.New(io.Discard, "DEBUG ", log.LstdFlags)
// setup command line flags.
var (
verbose bool
obfs4Cert string
obfs4Remote string
socksPort string
socksHost string
)
socksPort = "8080"
socksHost = "127.0.0.1"
flags := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
flags.BoolVar(&verbose, "v", verbose, "Enable verbose logging")
flags.StringVar(&obfs4Cert, "c", obfs4Cert, "The remote obfs4 certificate")
flags.StringVar(&obfs4Remote, "r", obfs4Remote, "The remote obfs4 endpoint (ip:port)")
flags.StringVar(&socksPort, "p", socksPort, "The port for the local socks5 proxy (default: 8080)")
flags.StringVar(&socksHost, "i", socksHost, "The host for the local socks5 proxy (default: localhost)")
err := flags.Parse(os.Args[1:])
if err != nil {
logger.Fatalf("error parsing flags: %v", err)
}
// Configure logging.
if verbose {
debug.SetOutput(os.Stderr)
}
kcpTransport := false
// TODO make this configurable via a Config struct
// TODO make sure we're disabling all the crypto options for KCP
if os.Getenv("KCP") == "1" {
kcpTransport = true
}
socksAddr := net.JoinHostPort(socksHost, socksPort)
c := client.NewClient(kcpTransport, socksAddr, obfs4Cert)
_, err = c.Start()
if err != nil {
log.Fatal(err)
}
}
|