forked from quantum1423-dustbin/kirisurf-legacy
/
main.go
40 lines (37 loc) · 1018 Bytes
/
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
// kirisurf project main.go
package main
import (
"encoding/base32"
"kirisurf/ll/dirclient"
"kirisurf/ll/kicrypt"
"kirisurf/ll/kiss"
"runtime"
"strconv"
"strings"
"time"
)
var MasterKey = kicrypt.SecureDH_genpair()
var MasterKeyHash = strings.ToLower(base32.StdEncoding.EncodeToString(
kicrypt.InvariantHash(MasterKey.Public.Bytes())[:20]))
func main() {
kiss.SetCipher(kicrypt.AS_aes256_ofb)
INFO("Kirisurf started! CPU count: %d", runtime.NumCPU())
runtime.GOMAXPROCS(runtime.NumCPU())
go run_monitor_loop()
go run_diagnostic_loop()
dirclient.DIRADDR = MasterConfig.General.DirectoryURL
dirclient.RefreshDirectory()
if MasterConfig.General.Role == "server" {
NewSCServer(MasterConfig.General.ORAddr)
prt, _ := strconv.Atoi(
strings.Split(MasterConfig.General.ORAddr, ":")[1])
dirclient.RunRelay(prt, MasterKeyHash,
MasterConfig.General.IsExit)
for {
time.Sleep(time.Second)
}
} else if MasterConfig.General.Role == "client" {
run_client_loop()
}
INFO("Kirisurf exited")
}