将节点分为普通节点和控制节点

This commit is contained in:
Mob2003
2023-03-31 11:58:47 +08:00
parent 88e128f941
commit 3b9a9cf4e1
28 changed files with 644 additions and 236 deletions
+7 -2
View File
@@ -1,8 +1,11 @@
package server
import (
"encoding/binary"
"errors"
"fmt"
"math/rand"
"rakshasa/cert"
"rakshasa/common"
"strconv"
"strings"
@@ -20,9 +23,11 @@ func StartRemoteSocks5(cfg *common.Addr, n *node) error {
server: n,
typ: "socks5",
result: make(chan interface{}),
randkey: make([]byte,8),
}
binary.LittleEndian.PutUint64(l.randkey,uint64(rand.NewSource(time.Now().UnixNano()).Int63()))
l.openOption = common.CMD_REMOTE_SOCKS5
l.openMsg = []byte(cfg.String())
l.openMsg = cert.RSAEncrypterByPrivByte(append(l.randkey,cfg.String()...))
n.Write(l.openOption, l.id, l.openMsg)
currentNode.listenMap.Store(l.id, l)
select {
@@ -110,7 +115,7 @@ func init() {
c.Println("没有找到ID为", id, "的连接")
} else {
l.Close("命令行关闭")
l.server.Write(common.CMD_DELETE_LISTEN, l.id, nil)
l.server.Write(common.CMD_DELETE_LISTEN, l.id, l.randkey)
currentNode.listenMap.Delete(uint32(id))
}