forked from MrOplus/bridge
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
55 lines (43 loc) · 1.12 KB
/
main.go
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
package main
import (
"context"
"fmt"
"time"
"github.com/doorbash/bridge/adapter/outbound"
"github.com/doorbash/bridge/log"
)
func main() {
ssrNode := make(map[string]interface{})
ssrNode["name"] = "ssr"
ssrNode["type"] = "ssr"
ssrNode["server"] = "1.2.3.4"
ssrNode["port"] = 11800
ssrNode["password"] = "1234"
ssrNode["cipher"] = "aes-256-cfb"
ssrNode["obfs"] = "http_simple"
ssrNode["obfs-param"] = ""
ssrNode["protocol"] = "origin"
ssrNode["protocol-param"] = ""
ssrNode["udp"] = true
p, err := outbound.ParseProxy(ssrNode)
socks5Node := make(map[string]interface{})
socks5Node["name"] = "socks"
socks5Node["type"] = "socks5"
socks5Node["server"] = "127.0.0.1"
socks5Node["port"] = 8080
socks5Node["udp"] = true
socks5Node["skip-cert-verify"] = true
ps, _ := outbound.ParseProxy(socks5Node)
p.SetDialer(ps)
if err != nil {
fmt.Println(err)
}
url := "https://api.ipify.org/"
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
body, latency, err := p.URLTest(ctx, url, true)
if err != nil {
panic(err)
}
log.Info("%s\nlatency: %d ms", body, latency)
}