-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utils.go
49 lines (45 loc) · 1.04 KB
/
test_utils.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
package dswg
func setupDB() DB {
db, _ := OpenSqliteDB(":memory:")
return db
}
func baseLink() Link {
addr1, _ := ParseIPNet("10.6.6.1/24")
addr2, _ := ParseIPNet("10.6.6.2/24")
ipv4, _ := ParseIPNet("10.6.6.1/24")
ipv6, _ := ParseIPNet("2001:0000::/32")
dns1, _ := ParseIP("1.1.1.1")
key, _ := ParseKey("4AQ6d+dvykkl4j6VG03e7VcciDbgn5mBEJFXMjn1pnU=")
return Link{
Name: "wg-linko",
MTU: 1420,
Enable: true,
PrivateKey: *key,
ListenPort: 9977,
FirewallMark: 42069,
AddressIPv4: ipv4,
AddressIPv6: ipv6,
DefaultDNS1: dns1,
PostDown: []string{"cmd1", "cmd2"},
PostUp: []string{"cmd3"},
DefaultAllowedIPs: []IPNet{*addr1, *addr2},
Forward: false,
}
}
func basePeer() Peer {
key, _ := ParseKey("ZOZ+ngJZ2jf+sREdOi/b0D8rTGMbcjgSA854Jn2KbzQ=")
dns1, _ := ParseIP("1.1.1.1")
endpoint, _ := ParseUDP("192.168.0.1:42064")
return Peer{
Name: "zoz-pc",
Enable: true,
PublicKey: *key,
PresharedKey: key,
Endpoint: endpoint,
DNS1: dns1,
}
}
func baseClient() Client {
client, _ := NewClient(setupDB())
return *client
}