generate protobuf files on the fly

This commit is contained in:
Darien Raymond committed 2017-01-02 20:43:41 +01:00
1 parent 52e1dfaeac
commit 7cbef6723c
7 files changed
+71 -5

No files matched your search

+2 -2
View File
@@ -1,2 +1,2 @@
.generated.go *.generated.go
.pb.go *.pb.go
+1
View File
@@ -5,6 +5,7 @@ go_import_path: v2ray.com/core
git: git:
depth: 5 depth: 5
script: script:
- go generate v2ray.com/core/...
- go test -tags json v2ray.com/core/... - go test -tags json v2ray.com/core/...
after_success: after_success:
- ./testing/coverage/coverall - ./testing/coverage/coverall
+1 -1
View File
@@ -55,7 +55,7 @@ func ChaCha20Block(s *[16]uint32, out []byte, rounds int) {
} }
func main() { func main() {
file, err := os.OpenFile("chacha_core_generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) file, err := os.OpenFile("chacha_core.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil { if err != nil {
log.Fatalf("Failed to generate chacha_core.go: %v", err) log.Fatalf("Failed to generate chacha_core.go: %v", err)
} }
+7
View File
@@ -0,0 +1,7 @@
// +build windows darwin linux
package genproto
//go:generate go get -u "github.com/golang/protobuf/protoc-gen-go"
//go:generate go get -u "github.com/golang/protobuf/proto"
//go:generate go run main.go
+57
View File
@@ -0,0 +1,57 @@
// +build generate
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
var protocMap = map[string]string{
"windows": filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "windows", "protoc.exe"),
"darwin": filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "macos", "protoc"),
"linux": filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "linux", "protoc"),
}
func main() {
protofiles := make(map[string][]string)
protoc := protocMap[runtime.GOOS]
gosrc := filepath.Join(os.Getenv("GOPATH"), "src")
filepath.Walk(filepath.Join(gosrc, "v2ray.com", "core"), func(path string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println(err)
return err
}
if info.IsDir() {
return nil
}
dir := filepath.Dir(path)
filename := filepath.Base(path)
if strings.HasSuffix(filename, ".proto") {
protofiles[dir] = append(protofiles[dir], path)
}
return nil
})
for _, files := range protofiles {
args := []string{"--proto_path", gosrc, "--go_out", gosrc}
args = append(args, files...)
cmd := exec.Command(protoc, args...)
cmd.Env = append(cmd.Env, os.Environ()...)
output, err := cmd.CombinedOutput()
if len(output) > 0 {
fmt.Println(string(output))
}
if err != nil {
fmt.Println(err)
}
}
}
+2
View File
@@ -1,3 +1,5 @@
// +build fullgen
package geoip package geoip
//go:generate go run geoip_gen.go //go:generate go run geoip_gen.go
+1 -2
View File
@@ -1,3 +1,2 @@
package geoip package geoip
var ChinaIPs = []byte{10,8,10,4,1,0,1,0,16,24,10,8,10,4,1,0,2,0,16,23,10,8,10,4,1,0,8,0,16,21,10,8,10,4,1,0,32,0,16,19,10,8,10,4,1,1,0,0,16,24,10,8,10,4,1,1,2,0,16,23,10,8,10,4,1,1,4,0,16,22,10,8,10,4,1,1,8,0,16,24,10,8,10,4,1,1,9,0,16,24,10,8,10,4,1,1,10,0,16,23,10,8,10,4,1,1,12,0,16,22,10,8,10,4,1,1,16,0,16,20,10,8,10,4,1,1,32,0,16,19,10,8,10,4,1,2,0,0,16,23,10,8,10,4,1,2,2,0,16,24,10,8,10,4,1,2,4,0,16,24,10,8,10,4,1,2,5,0,16,24,10,8,10,4,1,2,6,0,16,23,10,8,10,4,1,2,8,0,16,24,10,8,10,4,1,2,9,0,16,24,10,8,10,4,1,2,10,0,16,23,10,8,10,4,1,2,12,0,16,22,10,8,10,4,1,2,16,0,16,20,10,8,10,4,1,2,32,0,16,19,10,8,10,4,1,2,64,0,16,18,10,8,10,4,1,3,0,0,16,16,10,8,10,4,1,4,1,0,16,24,10,8,10,4,1,4,2,0,16,23,10,8,10,4,1,4,4,0,16,24,10,8,10,4,1,4,5,0,16,24,10,8,10,4,1,4,6,0,16,23,10,8,10,4,1,4,8,0,16,21,10,8,10,4,1,4,16,0,16,20,10,8,10,4,1,4,32,0,16,19,10,8,10,4,1,4,64,0,16,18,10,8,10,4,1,8,0,0,16,16,10,8,10,4,1,10,0,0,16,21,10,8,10,4,1,10,8,0,16,23,10,8,10,4,1,10,11,0,16,24,10,8,10,4,1,10,12,0,16,22,10,8,10,4,1,10,16,0,16,20,10,8,10,4,1,10,32,0,16,19,10,8,10,4,1,10,64,0,16,18,10,8,10,4,1,12,0,0,16,14,10,8,10,4,1,24,0,0,16,13,10,8,10,4,1,45,0,0,16,16,10,8,10,4,1,48,0,0,16,15,10,8,10,4,1,50,0,0,16,16,10,8,10,4,1,51,0,0,16,16,10,8,10,4,1,56,0,0,16,13,10,8,10,4,1,68,0,0,16,14,10,8,10,4,1,80,0,0,16,13,10,8,10,4,1,88,0,0,16,14,10,8,10,4,1,92,0,0,16,15,10,8,10,4,1,94,0,0,16,15,10,8,10,4,1,116,0,0,16,14,10,8,10,4,1,180,0,0,16,14,10,8,10,4,1,184,0,0,16,15,10,8,10,4,1,188,0,0,16,14,10,8,10,4,1,192,0,0,16,13,10,8,10,4,1,202,0,0,16,15,10,8,10,4,1,204,0,0,16,14,10,8,10,4,14,0,0,0,16,21,10,8,10,4,14,0,12,0,16,22,10,8,10,4,14,1,0,0,16,22,10,8,10,4,14,1,24,0,16,22,10,8,10,4,14,1,96,0,16,22,10,8,10,4,14,1,108,0,16,22,10,8,10,4,14,16,0,0,16,12,10,8,10,4,14,102,128,0,16,22,10,8,10,4,14,102,156,0,16,22,10,8,10,4,14,102,180,0,16,22,10,8,10,4,14,103,0,0,16,16,10,8,10,4,14,104,0,0,16,13,10,8,10,4,14,112,0,0,16,12,10,8,10,4,14,130,0,0,16,15,10,8,10,4,14,134,0,0,16,15,10,8,10,4,14,144,0,0,16,12,10,8,10,4,14,192,4,0,16,22,10,8,10,4,14,192,56,0,16,22,10,8,10,4,14,192,60,0,16,22,10,8,10,4,14,192,76,0,16,22,10,8,10,4,14,196,0,0,16,15,10,8,10,4,14,204,0,0,16,15,10,8,10,4,14,208,0,0,16,12,10,8,10,4,27,0,128,0,16,22,10,8,10,4,27,0,132,0,16,22,10,8,10,4,27,0,160,0,16,22,10,8,10,4,27,0,164,0,16,22,10,8,10,4,27,0,188,0,16,22,10,8,10,4,27,0,204,0,16,22,10,8,10,4,27,0,208,0,16,22,10,8,10,4,27,0,212,0,16,22,10,8,10,4,27,8,0,0,16,13,10,8,10,4,27,16,0,0,16,12,10,8,10,4,27,34,232,0,16,21,10,8,10,4,27,36,0,0,16,14,10,8,10,4,27,40,0,0,16,13,10,8,10,4,27,50,40,0,16,21,10,8,10,4,27,50,128,0,16,17,10,8,10,4,27,54,72,0,16,21,10,8,10,4,27,54,152,0,16,21,10,8,10,4,27,54,192,0,16,18,10,8,10,4,27,98,208,0,16,20,10,8,10,4,27,98,224,0,16,19,10,8,10,4,27,99,128,0,16,17,10,8,10,4,27,103,0,0,16,16,10,8,10,4,27,106,128,0,16,18,10,8,10,4,27,106,204,0,16,22,10,8,10,4,27,109,32,0,16,19,10,8,10,4,27,109,124,0,16,22,10,8,10,4,27,112,0,0,16,18,10,8,10,4,27,112,80,0,16,20,10,8,10,4,27,112,112,0,16,22,10,8,10,4,27,112,116,0,16,22,10,8,10,4,27,113,128,0,16,18,10,8,10,4,27,115,0,0,16,17,10,8,10,4,27,116,44,0,16,22,10,8,10,4,27,121,72,0,16,21,10,8,10,4,27,121,120,0,16,21,10,8,10,4,27,123,232,0,16,22,10,8,10,4,27,128,0,0,16,15,10,8,10,4,27,131,220,0,16,22,10,8,10,4,27,144,0,0,16,16,10,8,10,4,27,148,0,0,16,14,10,8,10,4,27,152,0,0,16,13,10,8,10,4,27,184,0,0,16,13,10,8,10,4,27,192,0,0,16,11,10,8,10,4,27,224,0,0,16,14,10,8,10,4,36,0,0,0,16,22,10,8,10,4,36,0,8,0,16,21,10,8,10,4,36,0,16,0,16,20,10,8,10,4,36,0,32,0,16,19,10,8,10,4,36,0,64,0,16,18,10,8,10,4,36,0,128,0,16,17,10,8,10,4,36,1,0,0,16,16,10,8,10,4,36,4,0,0,16,14,10,8,10,4,36,16,0,0,16,12,10,8,10,4,36,32,0,0,16,14,10,8,10,4,36,36,0,0,16,16,10,8,10,4,36,37,0,0,16,19,10,8,10,4,36,37,36,0,16,23,10,8,10,4,36,37,39,0,16,24,10,8,10,4,36,37,40,0,16,21,10,8,10,4,36,37,48,0,16,20,10,8,10,4,36,40,0,0,16,13,10,8,10,4,36,48,0,0,16,15,10,8,10,4,36,51,0,0,16,16,10,8,10,4,36,56,0,0,16,13,10,8,10,4,36,96,0,0,16,11,10,8,10,4,36,128,0,0,16,10,10,8,10,4,36,192,0,0,16,11,10,8,10,4,36,248,0,0,16,14,10,8,10,4,36,254,0,0,16,16,10,8,10,4,36,255,116,0,16,22,10,8,10,4,36,255,128,0,16,22,10,8,10,4,36,255,164,0,16,22,10,8,10,4,36,255,172,0,16,22,10,8,10,4,36,255,176,0,16,22,10,8,10,4,36,255,192,0,16,22,10,8,10,4,39,0,0,0,16,24,10,8,10,4,39,0,2,0,16,23,10,8,10,4,39,0,4,0,16,22,10,8,10,4,39,0,8,0,16,21,10,8,10,4,39,0,16,0,16,20,10,8,10,4,39,0,32,0,16,19,10,8,10,4,39,0,64,0,16,18,10,8,10,4,39,0,128,0,16,17,10,8,10,4,39,64,0,0,16,11,10,8,10,4,39,96,0,0,16,13,10,8,10,4,39,104,0,0,16,14,10,8,10,4,39,108,0,0,16,16,10,8,10,4,39,128,0,0,16,10,10,8,10,4,40,72,0,0,16,15,10,8,10,4,40,125,128,0,16,17,10,8,10,4,40,126,64,0,16,18,10,8,10,4,42,0,0,0,16,22,10,8,10,4,42,0,8,0,16,21,10,8,10,4,42,0,16,0,16,21,10,8,10,4,42,0,24,0,16,22,10,8,10,4,42,0,32,0,16,19,10,8,10,4,42,0,128,0,16,17,10,8,10,4,42,1,0,0,16,19,10,8,10,4,42,1,32,0,16,20,10,8,10,4,42,1,48,0,16,21,10,8,10,4,42,1,56,0,16,22,10,8,10,4,42,1,128,0,16,17,10,8,10,4,42,4,0,0,16,14,10,8,10,4,42,48,0,0,16,15,10,8,10,4,42,50,0,Line truncated
var ChinaIPs = []byte{10, 8, 10, 4, 1, 0, 1, 0, 16, 24, 10, 8, 10, 4, 1, 0, 2, 0, 16, 23, 10, 8, 10, 4, 1, 0, 8, 0, 16, 21, 10, 8, 10, 4, 1, 0, 32, 0, 16, 19, 10, 8, 10, 4, 1, 1, 0, 0, 16, 24, 10, 8, 10, 4, 1, 1, 2, 0, 16, 23, 10, 8, 10, 4, 1, 1, 4, 0, 16, 22, 10, 8, 10, 4, 1, 1, 8, 0, 16, 24, 10, 8, 10, 4, 1, 1, 9, 0, 16, 24, 10, 8, 10, 4, 1, 1, 10, 0, 16, 23, 10, 8, 10, 4, 1, 1, 12, 0, 16, 22, 10, 8, 10, 4, 1, 1, 16, 0, 16, 20, 10, 8, 10, 4, 1, 1, 32, 0, 16, 19, 10, 8, 10, 4, 1, 2, 0, 0, 16, 23, 10, 8, 10, 4, 1, 2, 2, 0, 16, 24, 10, 8, 10, 4, 1, 2, 4, 0, 16, 24, 10, 8, 10, 4, 1, 2, 5, 0, 16, 24, 10, 8, 10, 4, 1, 2, 6, 0, 16, 23, 10, 8, 10, 4, 1, 2, 8, 0, 16, 24, 10, 8, 10, 4, 1, 2, 9, 0, 16, 24, 10, 8, 10, 4, 1, 2, 10, 0, 16, 23, 10, 8, 10, 4, 1, 2, 12, 0, 16, 22, 10, 8, 10, 4, 1, 2, 16, 0, 16, 20, 10, 8, 10, 4, 1, 2, 32, 0, 16, 19, 10, 8, 10, 4, 1, 2, 64, 0, 16, 18, 10, 8, 10, 4, 1, 3, 0, 0, 16, 16, 10, 8, 10, 4, 1, 4, 1, 0, 16, 24, 10, 8, 10, 4, 1, 4, 2, 0, 16, 23, 10, 8, 10, 4, 1, 4, 4, 0, 16, 24, 10, 8, 10, 4, 1, 4, 5, 0, 16, 24, 10, 8, 10, 4, 1, 4, 6, 0, 16, 23, 10, 8, 10, 4, 1, 4, 8, 0, 16, 21, 10, 8, 10, 4, 1, 4, 16, 0, 16, 20, 10, 8, 10, 4, 1, 4, 32, 0, 16, 19, 10, 8, 10, 4, 1, 4, 64, 0, 16, 18, 10, 8, 10, 4, 1, 8, 0, 0, 16, 16, 10, 8, 10, 4, 1, 10, 0, 0, 16, 21, 10, 8, 10, 4, 1, 10, 8, 0, 16, 23, 10, 8, 10, 4, 1, 10, 11, 0, 16, 24, 10, 8, 10, 4, 1, 10, 12, 0, 16, 22, 10, 8, 10, 4, 1, 10, 16, 0, 16, 20, 10, 8, 10, 4, 1, 10, 32, 0, 16, 19, 10, 8, 10, 4, 1, 10, 64, 0, 16, 18, 10, 8, 10, 4, 1, 12, 0, 0, 16, 14, 10, 8, 10, 4, 1, 24, 0, 0, 16, 13, 10, 8, 10, 4, 1, 45, 0, 0, 16, 16, 10, 8, 10, 4, 1, 48, 0, 0, 16, 15, 10, 8, 10, 4, 1, 50, 0, 0, 16, 16, 10, 8, 10, 4, 1, 51, 0, 0, 16, 16, 10, 8, 10, 4, 1, 56, 0, 0, 16, 13, 10, 8, 10, 4, 1, 68, 0, 0, 16, 14, 10, 8, 10, 4, 1, 80, 0, 0, 16, 13, 10, 8, 10, 4, 1, 88, 0, 0, 16, 14, 10, 8, 10, 4, 1, 92, 0, 0, 16, 15, 10, 8, 10, 4, 1, 94, 0, 0, 16, 15, 10, 8, 10, 4, 1, 116, 0, 0, 16, 14, 10, 8, 10, 4, 1, 180, 0, 0, 16, 14, 10, 8, 10, 4, 1, 184, 0, 0, 16, 15, 10, 8, 10, 4, 1, 188, 0, 0, 16, 14, 10, 8, 10, 4, 1, 192, 0, 0, 16, 13, 10, 8, 10, 4, 1, 202, 0, 0, 16, 15, 10, 8, 10, 4, 1, 204, 0, 0, 16, 14, 10, 8, 10, 4, 14, 0, 0, 0, 16, 21, 10, 8, 10, 4, 14, 0, 12, 0, 16, 22, 10, 8, 10, 4, 14, 1, 0, 0, 16, 22, 10, 8, 10, 4, 14, 1, 24, 0, 16, 22, 10, 8, 10, 4, 14, 1, 96, 0, 16, 22, 10, 8, 10, 4, 14, 1, 108, 0, 16, 22, 10, 8, 10, 4, 14, 16, 0, 0, 16, 12, 10, 8, 10, 4, 14, 102, 128, 0, 16, 22, 10, 8, 10, 4, 14, 102, 156, 0, 16, 22, 10, 8, 10, 4, 14, 102, 180, 0, 16, 22, 10, 8, 10, 4, 14, 103, 0, 0, 16, 16, 10, 8, 10, 4, 14, 104, 0, 0, 16, 13, 10, 8, 10, 4, 14, 112, 0, 0, 16, 12, 10, 8, 10, 4, 14, 130, 0, 0, 16, 15, 10, 8, 10, 4, 14, 134, 0, 0, 16, 15, 10, 8, 10, 4, 14, 144, 0, 0, 16, 12, 10, 8, 10, 4, 14, 192, 4, 0, 16, 22, 10, 8, 10, 4, 14, 192, 56, 0, 16, 22, 10, 8, 10, 4, 14, 192, 60, 0, 16, 22, 10, 8, 10, 4, 14, 192, 76, 0, 16, 22, 10, 8, 10, 4, 14, 196, 0, 0, 16, 15, 10, 8, 10, 4, 14, 204, 0, 0, 16, 15, 10, 8, 10, 4, 14, 208, 0, 0, 16, 12, 10, 8, 10, 4, 27, 0, 128, 0, 16, 22, 10, 8, 10, 4, 27, 0, 132, 0, 16, 22, 10, 8, 10, 4, 27, 0, 160, 0, 16, 22, 10, 8, 10, 4, 27, 0, 164, 0, 16, 22, 10, 8, 10, 4, 27, 0, 188, 0, 16, 22, 10, 8, 10, 4, 27, 0, 204, 0, 16, 22, 10, 8, 10, 4, 27, 0, 208, 0, 16, 22, 10, 8, 10, 4, 27, 0, 212, 0, 16, 22, 10, 8, 10, 4, 27, 8, 0, 0, 16, 13, 10, 8, 10, 4, 27, 16, 0, 0, 16, 12, 10, 8, 10, 4, 27, 34, 232, 0, 16, 21, 10, 8, 10, 4, 27, 36, 0, 0, 16, 14, 10, 8, 10, 4, 27, 40, 0, 0, 16, 13, 10, 8, 10, 4, 27, 50, 40, 0, 16, 21, 10, 8, 10, 4, 27, 50, 128, 0, 16, 17, 10, 8, 10, 4, 27, 54, 72, 0, 16, 21, 10, 8, 10, 4, 27, 54, 152, 0, 16, 21, 10, 8, 10, 4, 27, 54, 192, 0, 16, 18, 10, 8, 10, 4, 27, 98, 208, 0, 16, 20, 10, 8, 10, 4, 27, 98, 224, 0, 16, 19, 10, 8, 10, 4, 27, 99, 128, 0, 16, 17, 10, 8, 10, 4, 27, 103, 0, 0, 16, 16, 10, 8, 10, 4, 27, 106, 128, 0, 16, 18, 10, 8, 10, 4, 27, 106, 204, 0, 16, 22, 10, 8, 10, 4, 27, 109, 32, 0, 16, 19, 10, 8, 10, 4, 27, 109, 124, 0, 16, 22, 10, 8, 10, 4, 27, 112, 0, 0, 16, 18, 10, 8, 10, 4, 27, 112, 80, 0, 16, 20, 10, 8, 10, 4, 27, 112, 112, 0, 16, 22, 10, 8, 10, 4, 27, 112, 116, 0, 16, 22, 10, 8, 10, 4, 27, 113, 128, 0, 16, 18, 10, 8, 10, 4, 27, 115, 0, 0, 16, 17, 10, 8, 10, 4, 27, 116, 44, 0, 16, 22, 10, 8, 10, 4, 27, 121, 72, 0, 16, 21, 10, 8, 10, 4, 27, 121, 120, 0, 16, 21, 10, 8, 10, 4, 27, 123, 232, 0, 16, 22, 10, 8, 10, 4, 27, 128, 0, 0, 16, 15, 10, 8, 10, 4, 27, 131, 220, 0, 16, 22, 10, 8, 10, 4, 27, 144, 0, 0, 16, 16, 10, 8, 10, 4, 27, 148, 0, 0, 16, 14, 10, 8, 10, 4, 27, 152, 0, 0, 16, 13, 10, 8, 10, 4, 27, 184, 0, 0, 16, 13, 10, 8, 10, 4, 27, 192, 0, 0, 16, 11, 10, 8, 10, 4, 27, 224, 0, 0, 16, 14, 10, 8, 10, 4, 36, 0, 0, 0, 16, 22, 10, 8, 10, 4, 36, 0, 8, 0, 16, 21, 10, 8, 10, 4, 36, 0, 16, 0, 16, 20, 10, 8, 10, 4, 36, 0, 32, 0, 16, 19, 10, 8, 10, 4, 36, 0, 64, 0, 16, 18, 10, 8, 10, 4, 36, 0, 128, 0, 16, 17, 10, 8, 10, 4, 36, 1, 0, 0, 16, 16, 10, 8, 10, 4, 36, 4, 0, 0, 16, 14, 10, 8, 10, 4, 36, 16, 0, 0, 1Line truncated