mirror of https://github.com/v2ray/v2ray-core
generator for china ip
parent
7e481fe943
commit
0cedf8ad7d
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,15 @@
|
||||||
|
// +build generate
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -52,9 +56,28 @@ func main() {
|
||||||
ipNet.Add(t)
|
ipNet.Add(t)
|
||||||
}
|
}
|
||||||
dump := ipNet.Serialize()
|
dump := ipNet.Serialize()
|
||||||
fmt.Println("map[uint32]byte {")
|
|
||||||
for i := 0; i < len(dump); i += 2 {
|
file, err := os.OpenFile("chinaip_init.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
fmt.Println(dump[i], ": ", dump[i+1], ",")
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to generate chinaip_init.go: %v", err)
|
||||||
}
|
}
|
||||||
fmt.Println("}")
|
defer file.Close()
|
||||||
|
|
||||||
|
fmt.Fprintln(file, "package rules")
|
||||||
|
fmt.Fprintln(file, "import (")
|
||||||
|
fmt.Fprintln(file, "v2net \"github.com/v2ray/v2ray-core/common/net\"")
|
||||||
|
fmt.Fprintln(file, ")")
|
||||||
|
|
||||||
|
fmt.Fprintln(file, "var (")
|
||||||
|
fmt.Fprintln(file, "chinaIPNet *v2net.IPNet")
|
||||||
|
fmt.Fprintln(file, ")")
|
||||||
|
|
||||||
|
fmt.Fprintln(file, "func init() {")
|
||||||
|
|
||||||
|
fmt.Fprintln(file, "chinaIPNet = v2net.NewIPNetInitialValue(map[uint32]byte {")
|
||||||
|
for i := 0; i < len(dump); i += 2 {
|
||||||
|
fmt.Fprintln(file, dump[i], ": ", dump[i+1], ",")
|
||||||
|
}
|
||||||
|
fmt.Fprintln(file, "})")
|
||||||
|
fmt.Fprintln(file, "}")
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue