github.com/xraypb/Xray-core@v1.8.1/infra/conf/wireguard_test.go (about) 1 package conf_test 2 3 import ( 4 "testing" 5 6 . "github.com/xraypb/Xray-core/infra/conf" 7 "github.com/xraypb/Xray-core/proxy/wireguard" 8 ) 9 10 func TestWireGuardOutbound(t *testing.T) { 11 creator := func() Buildable { 12 return new(WireGuardConfig) 13 } 14 15 runMultiTestCase(t, []TestCase{ 16 { 17 Input: `{ 18 "secretKey": "uJv5tZMDltsiYEn+kUwb0Ll/CXWhMkaSCWWhfPEZM3A=", 19 "address": ["10.1.1.1", "fd59:7153:2388:b5fd:0000:0000:1234:0001"], 20 "peers": [ 21 { 22 "publicKey": "6e65ce0be17517110c17d77288ad87e7fd5252dcc7d09b95a39d61db03df832a", 23 "endpoint": "127.0.0.1:1234" 24 } 25 ], 26 "mtu": 1300, 27 "workers": 2 28 }`, 29 Parser: loadJSON(creator), 30 Output: &wireguard.DeviceConfig{ 31 // key converted into hex form 32 SecretKey: "b89bf9b5930396db226049fe914c1bd0b97f0975a13246920965a17cf1193370", 33 Endpoint: []string{"10.1.1.1", "fd59:7153:2388:b5fd:0000:0000:1234:0001"}, 34 Peers: []*wireguard.PeerConfig{ 35 { 36 // also can read from hex form directly 37 PublicKey: "6e65ce0be17517110c17d77288ad87e7fd5252dcc7d09b95a39d61db03df832a", 38 PreSharedKey: "0000000000000000000000000000000000000000000000000000000000000000", 39 Endpoint: "127.0.0.1:1234", 40 KeepAlive: 0, 41 AllowedIps: []string{"0.0.0.0/0", "::0/0"}, 42 }, 43 }, 44 Mtu: 1300, 45 NumWorkers: 2, 46 }, 47 }, 48 }) 49 }