mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
move error generator to common
This commit is contained in:
parent
5e27e3d260
commit
d43a23aa96
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"net"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Package proxyman defines applications for manageing inbound and outbound proxies.
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See each sub-package for detail.
|
||||
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.
|
||||
func Must(err error) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Package crypto provides common crypto libraries for V2Ray.
|
||||
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
|
||||
|
47
common/errors/errorgen/main.go
Normal file
47
common/errors/errorgen/main.go
Normal 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())
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// Package net is a drop-in replacement to Golang's net package, with some more functionalities.
|
||||
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
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"time"
|
||||
|
2
core.go
2
core.go
@ -9,7 +9,7 @@
|
||||
// connections.
|
||||
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 (
|
||||
"fmt"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"flag"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Package blackhole is an outbound handler that blocks all connections.
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -5,7 +5,7 @@
|
||||
// 2. Register a config creator through common.RegisterConfig.
|
||||
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 (
|
||||
"context"
|
||||
|
@ -13,4 +13,4 @@
|
||||
// R.I.P 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Package socks provides implements of Socks protocol 4, 4a and 5.
|
||||
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
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"context"
|
||||
|
@ -5,7 +5,7 @@
|
||||
// clients with 'socks' for proxying.
|
||||
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 (
|
||||
"context"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 (
|
||||
"bytes"
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -5,4 +5,4 @@
|
||||
// xtaci@github for translating to Golang
|
||||
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
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"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 (
|
||||
_ buf.Writer = (*conn)(nil)
|
||||
|
@ -1,3 +1,3 @@
|
||||
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
|
||||
|
@ -4,4 +4,4 @@ Websocket transport implements a HTTP(S) compliable, surveillance proof transpor
|
||||
*/
|
||||
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
|
||||
|
2
v2ray.go
2
v2ray.go
@ -121,7 +121,7 @@ func newSimpleServer(config *Config) (*simpleServer, error) {
|
||||
if p := policy.FromSpace(space); p == nil {
|
||||
p, err := app.CreateAppFromConfig(ctx, &policy.Config{
|
||||
Level: map[uint32]*policy.Policy{
|
||||
1: &policy.Policy{
|
||||
1: {
|
||||
Timeout: &policy.Policy_Timeout{
|
||||
ConnectionIdle: &policy.Second{
|
||||
Value: 600,
|
||||
|
Loading…
Reference in New Issue
Block a user