Skip to content

Commit 58d0490

Browse files
bincooobincooo
authored andcommitted
style: 伪装ip无用,删除相关代码
1 parent 4f6b435 commit 58d0490

1 file changed

Lines changed: 0 additions & 69 deletions

File tree

chat.go

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/google/uuid"
1111
"github.com/sirupsen/logrus"
1212
"io"
13-
"math/rand"
1413
"net/http"
1514
"net/url"
1615
"strconv"
@@ -516,7 +515,6 @@ func (c *Chat) initHeader() http.Header {
516515
h.Set(k, v)
517516
}
518517
}
519-
h.Set("X-Forwarded-For", randomIp())
520518
return h
521519
}
522520

@@ -532,70 +530,3 @@ func deleteItem[T any](slice []T, condition func(item T) bool) []T {
532530
}
533531
return slice
534532
}
535-
536-
// 获取随机ip
537-
// https://github.com/Harry-zklcdc/go-proxy-bingai/blob/fb6adba0da2745840bea5ce285097e84ecd085ab/cloudflare/worker.js#L97
538-
func randomIp() string {
539-
r := rand.New(rand.NewSource(time.Now().UnixNano()))
540-
ip2Int := func(ip string) int {
541-
slice := strings.Split(ip, ".")
542-
result := 0
543-
atoi, _ := strconv.Atoi(slice[0])
544-
result += atoi << 24
545-
atoi, _ = strconv.Atoi(slice[1])
546-
result += atoi << 16
547-
atoi, _ = strconv.Atoi(slice[2])
548-
result += atoi << 8
549-
atoi, _ = strconv.Atoi(slice[2])
550-
result += atoi
551-
return result
552-
}
553-
554-
int2Ip := func(num int) (result string) {
555-
result += strconv.Itoa(num>>24&255) + "."
556-
result += strconv.Itoa(num>>16&255) + "."
557-
result += strconv.Itoa(num>>8&255) + "."
558-
result += strconv.Itoa(num & 255)
559-
return
560-
}
561-
562-
randIndex := r.Intn(len(IP_RANGE))
563-
startIPInt := ip2Int(IP_RANGE[randIndex][0])
564-
endIPInt := ip2Int(IP_RANGE[randIndex][1])
565-
566-
newIpInt := r.Intn(endIPInt-startIPInt) + startIPInt
567-
return int2Ip(newIpInt)
568-
}
569-
570-
var IP_RANGE = [][]string{
571-
{"4.150.64.0", "4.150.127.255"}, // Azure Cloud EastUS2 16382
572-
{"4.152.0.0", "4.153.255.255"}, // Azure Cloud EastUS2 131070
573-
{"13.68.0.0", "13.68.127.255"}, // Azure Cloud EastUS2 32766
574-
{"13.104.216.0", "13.104.216.255"}, // Azure EastUS2 256
575-
{"20.1.128.0", "20.1.255.255"}, // Azure Cloud EastUS2 32766
576-
{"20.7.0.0", "20.7.255.255"}, // Azure Cloud EastUS2 65534
577-
{"20.22.0.0", "20.22.255.255"}, // Azure Cloud EastUS2 65534
578-
{"40.84.0.0", "40.84.127.255"}, // Azure Cloud EastUS2 32766
579-
{"40.123.0.0", "40.123.127.255"}, // Azure Cloud EastUS2 32766
580-
{"4.214.0.0", "4.215.255.255"}, // Azure Cloud JapanEast 131070
581-
{"4.241.0.0", "4.241.255.255"}, // Azure Cloud JapanEast 65534
582-
{"40.115.128.0", "40.115.255.255"}, // Azure Cloud JapanEast 32766
583-
{"52.140.192.0", "52.140.255.255"}, // Azure Cloud JapanEast 16382
584-
{"104.41.160.0", "104.41.191.255"}, // Azure Cloud JapanEast 8190
585-
{"138.91.0.0", "138.91.15.255"}, // Azure Cloud JapanEast 4094
586-
{"151.206.65.0", "151.206.79.255"}, // Azure Cloud JapanEast 256
587-
{"191.237.240.0", "191.237.241.255"}, // Azure Cloud JapanEast 512
588-
{"4.208.0.0", "4.209.255.255"}, // Azure Cloud NorthEurope 131070
589-
{"52.169.0.0", "52.169.255.255"}, // Azure Cloud NorthEurope 65534
590-
{"68.219.0.0", "68.219.127.255"}, // Azure Cloud NorthEurope 32766
591-
{"65.52.64.0", "65.52.79.255"}, // Azure Cloud NorthEurope 4094
592-
{"98.71.0.0", "98.71.127.255"}, // Azure Cloud NorthEurope 32766
593-
{"74.234.0.0", "74.234.127.255"}, // Azure Cloud NorthEurope 32766
594-
{"4.151.0.0", "4.151.255.255"}, // Azure Cloud SouthCentralUS 65534
595-
{"13.84.0.0", "13.85.255.255"}, // Azure Cloud SouthCentralUS 131070
596-
{"4.255.128.0", "4.255.255.255"}, // Azure Cloud WestCentralUS 32766
597-
{"13.78.128.0", "13.78.255.255"}, // Azure Cloud WestCentralUS 32766
598-
{"4.175.0.0", "4.175.255.255"}, // Azure Cloud WestEurope 65534
599-
{"13.80.0.0", "13.81.255.255"}, // Azure Cloud WestEurope 131070
600-
{"20.73.0.0", "20.73.255.255"}, // Azure Cloud WestEurope 65534
601-
}

0 commit comments

Comments
 (0)