Browse Source

remove v2ray logger

pull/15/head
Jason 5 years ago
parent
commit
e8eafb6186
  1. 69
      common/log/v2ray/logger.go
  2. 5
      proxy/d/tcp.go

69
common/log/v2ray/logger.go

@ -1,69 +0,0 @@
package v2ray
import (
"fmt"
"os"
vlog "v2ray.com/core/common/log"
"github.com/xjasonlyu/tun2socks/common/log"
)
type v2rayLogger struct {
handler vlog.Handler
level vlog.Severity
}
func NewV2RayLogger() log.Logger {
handler := vlog.NewLogger(vlog.CreateStdoutLogWriter())
return &v2rayLogger{handler: handler, level: vlog.Severity_Info}
}
func (l *v2rayLogger) SetLevel(level log.LogLevel) {
switch level {
case log.DEBUG:
l.level = vlog.Severity_Debug
case log.INFO:
l.level = vlog.Severity_Info
case log.WARN:
l.level = vlog.Severity_Warning
case log.ERROR:
l.level = vlog.Severity_Error
case log.NONE:
l.level = vlog.Severity_Unknown
}
}
func (l *v2rayLogger) Debugf(msg string, args ...interface{}) {
l.output(vlog.Severity_Debug, msg, args...)
}
func (l *v2rayLogger) Infof(msg string, args ...interface{}) {
l.output(vlog.Severity_Info, msg, args...)
}
func (l *v2rayLogger) Warnf(msg string, args ...interface{}) {
l.output(vlog.Severity_Warning, msg, args...)
}
func (l *v2rayLogger) Errorf(msg string, args ...interface{}) {
l.output(vlog.Severity_Error, msg, args...)
}
func (l *v2rayLogger) Fatalf(msg string, args ...interface{}) {
l.output(vlog.Severity_Unknown, msg, args...)
os.Exit(1)
}
func (l *v2rayLogger) output(level vlog.Severity, msg string, args ...interface{}) {
if level <= l.level {
l.handler.Handle(&vlog.GeneralMessage{
Severity: level,
Content: fmt.Sprintf(msg, args...),
})
}
}
func init() {
log.RegisterLogger(NewV2RayLogger())
}

5
proxy/d/tcp.go

@ -26,11 +26,6 @@ import (
// Where 192.168.1.189 is the default interface address, in my case, it's the WiFi interface and it's en0.
// 192.168.1.1 is the default gateway.
// It's very important to have two default routes, and the default route to TUN should has the highest priority.
//
// Start v2ray (or any other chainable proxy clients) and has SOCKS inbound listen on 127.0.0.1:1086.
//
// Optinally with all outbounds have sendThrough set to 192.168.1.189, if applicable.
// https://v2ray.com/chapter_02/01_overview.html#outboundobject
type tcpHandler struct {
proxyHandler core.TCPConnHandler

Loading…
Cancel
Save