1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

move error generator to common

This commit is contained in:
Darien Raymond 2017-12-03 01:04:57 +01:00
parent 5e27e3d260
commit d43a23aa96
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
38 changed files with 84 additions and 37 deletions

View File

@ -1,3 +1,3 @@
package app package app
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg app -path App //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg app -path App

View File

@ -1,6 +1,6 @@
package impl package impl
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg impl -path App,Dispatcher,Default //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg impl -path App,Dispatcher,Default
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package dns package dns
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg dns -path App,DNS //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg dns -path App,DNS
import ( import (
"net" "net"

View File

@ -1,6 +1,6 @@
package server package server
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg server -path App,DNS,Server //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg server -path App,DNS,Server
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package log package log
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg log -path App,Log //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg log -path App,Log
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package inbound package inbound
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg inbound -path App,Proxyman,Inbound //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg inbound -path App,Proxyman,Inbound
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package mux package mux
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg mux -path App,Proxyman,Mux //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg mux -path App,Proxyman,Mux
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package outbound package outbound
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg outbound -path App,Proxyman,Outbound //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg outbound -path App,Proxyman,Outbound
import ( import (
"context" "context"

View File

@ -1,7 +1,7 @@
// Package proxyman defines applications for manageing inbound and outbound proxies. // Package proxyman defines applications for manageing inbound and outbound proxies.
package proxyman package proxyman
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg proxyman -path App,Proxyman //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg proxyman -path App,Proxyman
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package router package router
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg router -path App,Router //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg router -path App,Router
import ( import (
"context" "context"

View File

@ -1,3 +1,3 @@
package buf package buf
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg buf -path Buf //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg buf -path Buf

View File

@ -2,7 +2,7 @@
// See each sub-package for detail. // See each sub-package for detail.
package common package common
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg common -path Common //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg common -path Common
// Must panics if err is not nil. // Must panics if err is not nil.
func Must(err error) { func Must(err error) {

View File

@ -1,4 +1,4 @@
// Package crypto provides common crypto libraries for V2Ray. // Package crypto provides common crypto libraries for V2Ray.
package crypto package crypto
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg crypto -path Crypto //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg crypto -path Crypto

View File

@ -0,0 +1,47 @@
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
"v2ray.com/core/common"
)
var (
pkg = flag.String("pkg", "", "Target package")
path = flag.String("path", "", "Path")
)
func main() {
flag.Parse()
if len(*pkg) == 0 {
panic("Package is not specified.")
}
if len(*path) == 0 {
panic("Path is not specified.")
}
paths := strings.Split(*path, ",")
for i := range paths {
paths[i] = "\"" + paths[i] + "\""
}
pathStr := strings.Join(paths, ", ")
file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
log.Fatalf("Failed to generate errors.generated.go: %v", err)
}
common.Must2(fmt.Fprintln(file, "package", *pkg))
common.Must2(fmt.Fprintln(file, ""))
common.Must2(fmt.Fprintln(file, "import \"v2ray.com/core/common/errors\""))
common.Must2(fmt.Fprintln(file, ""))
common.Must2(fmt.Fprintln(file, "func newError(values ...interface{}) *errors.Error { return errors.New(values...).Path("+pathStr+") }"))
common.Must(file.Close())
}

View File

@ -1,4 +1,4 @@
// Package net is a drop-in replacement to Golang's net package, with some more functionalities. // Package net is a drop-in replacement to Golang's net package, with some more functionalities.
package net package net
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg net -path Net //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg net -path Net

View File

@ -1,3 +1,3 @@
package protocol package protocol
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg protocol -path Protocol //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg protocol -path Protocol

View File

@ -1,6 +1,6 @@
package retry package retry
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg retry -path Retry //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg retry -path Retry
import ( import (
"time" "time"

View File

@ -9,7 +9,7 @@
// connections. // connections.
package core package core
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg core -path Core //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg core -path Core
import ( import (
"fmt" "fmt"

View File

@ -1,6 +1,6 @@
package main package main
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg main -path Main //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg main -path Main
import ( import (
"flag" "flag"

View File

@ -1,7 +1,7 @@
// Package blackhole is an outbound handler that blocks all connections. // Package blackhole is an outbound handler that blocks all connections.
package blackhole package blackhole
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg blackhole -path Proxy,Blackhole //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg blackhole -path Proxy,Blackhole
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package dokodemo package dokodemo
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg dokodemo -path Proxy,Dokodemo //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg dokodemo -path Proxy,Dokodemo
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package freedom package freedom
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg freedom -path Proxy,Freedom //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg freedom -path Proxy,Freedom
import ( import (
"context" "context"

View File

@ -1,3 +1,3 @@
package http package http
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg http -path Proxy,HTTP //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg http -path Proxy,HTTP

View File

@ -5,7 +5,7 @@
// 2. Register a config creator through common.RegisterConfig. // 2. Register a config creator through common.RegisterConfig.
package proxy package proxy
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg proxy -path Proxy //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg proxy -path Proxy
import ( import (
"context" "context"

View File

@ -13,4 +13,4 @@
// R.I.P Shadowsocks // R.I.P Shadowsocks
package shadowsocks package shadowsocks
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg shadowsocks -path Proxy,Shadowsocks //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg shadowsocks -path Proxy,Shadowsocks

View File

@ -1,4 +1,4 @@
// Package socks provides implements of Socks protocol 4, 4a and 5. // Package socks provides implements of Socks protocol 4, 4a and 5.
package socks package socks
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg socks -path Proxy,Socks //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg socks -path Proxy,Socks

View File

@ -1,3 +1,3 @@
package encoding package encoding
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg encoding -path Proxy,VMess,Encoding //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg encoding -path Proxy,VMess,Encoding

View File

@ -1,6 +1,6 @@
package inbound package inbound
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg inbound -path Proxy,VMess,Inbound //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg inbound -path Proxy,VMess,Inbound
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package outbound package outbound
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg outbound -path Proxy,VMess,Outbound //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg outbound -path Proxy,VMess,Outbound
import ( import (
"context" "context"

View File

@ -5,7 +5,7 @@
// clients with 'socks' for proxying. // clients with 'socks' for proxying.
package vmess package vmess
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg vmess -path Proxy,VMess //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg vmess -path Proxy,VMess
import ( import (
"context" "context"

View File

@ -1,6 +1,6 @@
package http package http
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg http -path Transport,Internet,Headers,HTTP //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg http -path Transport,Internet,Headers,HTTP
import ( import (
"bytes" "bytes"

View File

@ -1,3 +1,3 @@
package internet package internet
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg internet -path Transport,Internet //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg internet -path Transport,Internet

View File

@ -5,4 +5,4 @@
// xtaci@github for translating to Golang // xtaci@github for translating to Golang
package kcp package kcp
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg kcp -path Transport,Internet,mKCP //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg kcp -path Transport,Internet,mKCP

View File

@ -1,3 +1,3 @@
package tcp package tcp
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg tcp -path Transport,Internet,TCP //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg tcp -path Transport,Internet,TCP

View File

@ -7,7 +7,7 @@ import (
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
) )
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg tls -path Transport,Internet,TLS //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg tls -path Transport,Internet,TLS
var ( var (
_ buf.Writer = (*conn)(nil) _ buf.Writer = (*conn)(nil)

View File

@ -1,3 +1,3 @@
package udp package udp
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg udp -path Transport,Internet,UDP //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg udp -path Transport,Internet,UDP

View File

@ -4,4 +4,4 @@ Websocket transport implements a HTTP(S) compliable, surveillance proof transpor
*/ */
package websocket package websocket
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg websocket -path Transport,Internet,WebSocket //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg websocket -path Transport,Internet,WebSocket

View File

@ -121,7 +121,7 @@ func newSimpleServer(config *Config) (*simpleServer, error) {
if p := policy.FromSpace(space); p == nil { if p := policy.FromSpace(space); p == nil {
p, err := app.CreateAppFromConfig(ctx, &policy.Config{ p, err := app.CreateAppFromConfig(ctx, &policy.Config{
Level: map[uint32]*policy.Policy{ Level: map[uint32]*policy.Policy{
1: &policy.Policy{ 1: {
Timeout: &policy.Policy_Timeout{ Timeout: &policy.Policy_Timeout{
ConnectionIdle: &policy.Second{ ConnectionIdle: &policy.Second{
Value: 600, Value: 600,