mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-18 20:58:10 +02:00
bunch of bugfix, supermode OK
This commit is contained in:
@@ -15,8 +15,8 @@ var (
|
||||
http_graph *path.IG
|
||||
http_device4 *device.Device
|
||||
http_device6 *device.Device
|
||||
http_NhTable_Hash string
|
||||
http_PeerInfo_hash string
|
||||
http_NhTable_Hash [32]byte
|
||||
http_PeerInfo_hash [32]byte
|
||||
http_NhTableStr []byte
|
||||
http_PeerInfoStr []byte
|
||||
http_PeerState map[string]*PeerState
|
||||
@@ -25,8 +25,8 @@ var (
|
||||
)
|
||||
|
||||
type PeerState struct {
|
||||
NhTableState string
|
||||
PeerInfoState string
|
||||
NhTableState [32]byte
|
||||
PeerInfoState [32]byte
|
||||
}
|
||||
|
||||
type client struct {
|
||||
@@ -43,7 +43,7 @@ func get_peerinfo(w http.ResponseWriter, r *http.Request) {
|
||||
PubKey, _ := params["PubKey"]
|
||||
State, _ := params["State"]
|
||||
if state := http_PeerState[PubKey[0]]; state != nil {
|
||||
http_PeerState[PubKey[0]].PeerInfoState = State[0]
|
||||
copy(http_PeerState[PubKey[0]].PeerInfoState[:], State[0])
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(http_PeerInfoStr))
|
||||
@@ -54,19 +54,18 @@ func get_nhtable(w http.ResponseWriter, r *http.Request) {
|
||||
PubKey, _ := params["PubKey"]
|
||||
State, _ := params["State"]
|
||||
if state := http_PeerState[PubKey[0]]; state != nil {
|
||||
http_PeerState[PubKey[0]].NhTableState = State[0]
|
||||
copy(http_PeerState[PubKey[0]].NhTableState[:], State[0])
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(http_NhTableStr))
|
||||
}
|
||||
|
||||
func HttpServer(http_port int, apiprefix string, graph *path.IG, device4 *device.Device, device6 *device.Device) {
|
||||
http_graph = graph
|
||||
http_device4 = device4
|
||||
http_device6 = device6
|
||||
http_PeerState = make(map[string]*PeerState)
|
||||
func HttpServer(http_port int, apiprefix string) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/"+apiprefix+"/peerinfo", get_peerinfo)
|
||||
mux.HandleFunc("/"+apiprefix+"/nhtable", get_nhtable)
|
||||
go http.ListenAndServe(":"+strconv.Itoa(http_port), mux)
|
||||
if apiprefix[0] != '/' {
|
||||
apiprefix = "/" + apiprefix
|
||||
}
|
||||
mux.HandleFunc(apiprefix+"/peerinfo", get_peerinfo)
|
||||
mux.HandleFunc(apiprefix+"/nhtable", get_nhtable)
|
||||
http.ListenAndServe(":"+strconv.Itoa(http_port), mux)
|
||||
}
|
||||
|
Reference in New Issue
Block a user