增加http_proxy重连逻辑

This commit is contained in:
Mob2003
2023-04-08 21:29:05 +08:00
parent b48e9e77ac
commit bd49fdc0bf
26 changed files with 356 additions and 289 deletions
+30 -11
View File
@@ -2,12 +2,14 @@ package common
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"math/rand"
"net"
"rakshasa/aes"
"regexp"
"strconv"
"strings"
"sync"
"sync/atomic"
@@ -195,17 +197,6 @@ func init() {
}
type RegMsg struct {
UUID string //当前机器uuid
RegAddr string //远程连接的addr
Hostname string //当前机器名称
Goos string
ViaUUID string
Err string
MainIp string
Port string
}
var msgId uint32
func (m *Msg) Marshal() []byte {
@@ -329,3 +320,31 @@ func ResolveTCPAddr(str string) ([]string, error) {
return dst, nil
}
func GetUUIDFromInterfaceMac() string {
ifts, _ := net.Interfaces()
for _, ift := range ifts {
if addr := ift.HardwareAddr.String(); len(addr) > 0 {
var randSeed = make([]byte, 8)
for k, s := range strings.Split(addr, ":") {
if k < 8 {
n, _ := strconv.ParseUint(s, 16, 8)
randSeed[k] = byte(n)
}
}
source := rand.NewSource(int64(binary.LittleEndian.Uint64(randSeed)))
buf := bytes.NewBuffer(nil)
for i := 0; i < 2; i++ {
var b = make([]byte, 8)
binary.LittleEndian.PutUint64(b, uint64(source.Int63()))
buf.Write(b)
}
id, err := uuid.NewRandomFromReader(buf)
if err == nil {
return id.String()
}
}
}
return uuid.New().String()
}
+2 -1
View File
@@ -1,10 +1,11 @@
package common
type Config struct {
UUID string //以指定uuid启动
DstNode []string //-d 上级节点
Password string //通讯密码,可为空
Port int //默认8883
ListenIp string //指定公网ip,其他节点进行额外节点连接时候,尝试连接的ip
ListenIp string //指定公网ip,其他节点进行额外节点连接时候,尝试连接的ip
Limit bool //禁止额外连接,只连接-d节点,不会尝试连接其他节点
FileName string
FileSave bool `yaml:"-"`