Skip to content

Commit

Permalink
add log level
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Mar 22, 2020
1 parent 519a721 commit 60d6f33
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type GlobalConfig struct {

Hash map[string]string
Passwords []string `json:"password"`
LogLevel int `json: "log_level"`
LogLevel int `json:"log_level"`
TLS TLSConfig `json:"ssl"`
TCP TCPConfig `json:"tcp"`
MySQL MySQLConfig `json:"mysql"`
Expand Down
7 changes: 5 additions & 2 deletions conf/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"strings"

"github.com/p4gefau1t/trojan-go/common"
"github.com/withmandala/go-log"
"github.com/p4gefau1t/trojan-go/log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

func ConvertToIP(s string) ([]net.IP, error) {
ip := net.ParseIP(s)
Expand Down Expand Up @@ -44,6 +44,9 @@ func ParseJSON(data []byte) (*GlobalConfig, error) {
if err != nil {
return nil, err
}

log.LogLevel = config.LogLevel

config.Hash = make(map[string]string)
for _, password := range config.Passwords {
config.Hash[common.SHA224String(password)] = password
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/smartystreets/goconvey v1.6.4
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a
github.com/withmandala/go-log v0.1.0
github.com/xtaci/smux v2.0.1+incompatible
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20200320220750-118fecf932d8
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/withmandala/go-log v0.1.0 h1:wINmTEe7BQ6zEA8sE7lSsYeaxCLluK6RFjF/IB5tzkA=
github.com/withmandala/go-log v0.1.0/go.mod h1:/V9xQUTW74VjYm3u2Liv/bIUGLWoL9z2GlHwtscp4vg=
github.com/xtaci/smux v2.0.1+incompatible h1:4NrCD5VzuFktMCxK08IShR0C5vKyNICJRShUzvk0U34=
github.com/xtaci/smux v2.0.1+incompatible/go.mod h1:f+nYm6SpuHMy/SH0zpbvAFHT1QoMcgLOsWcFip5KfPw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
Expand Down
2 changes: 1 addition & 1 deletion log/colorful/colorful.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package colorful

import "github.com/withmandala/go-log/buffer"
import "github.com/p4gefau1t/trojan-go/log/buffer"

// ColorBuffer add color option to buffer append
type ColorBuffer struct {
Expand Down
2 changes: 1 addition & 1 deletion log/colorful/colorful_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package colorful
import (
"testing"

"github.com/p4gefau1t/trojan-go/log/buffer"
. "github.com/smartystreets/goconvey/convey"
"github.com/withmandala/go-log/buffer"
)

func TestColorBuffer(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync"
"time"

"github.com/withmandala/go-log/colorful"
"github.com/p4gefau1t/trojan-go/log/colorful"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"os/signal"

"github.com/p4gefau1t/trojan-go/conf"
"github.com/p4gefau1t/trojan-go/log"
"github.com/p4gefau1t/trojan-go/proxy"
"github.com/withmandala/go-log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

func main() {
logger.Info("Trojan-Go initializing...")
Expand Down
4 changes: 2 additions & 2 deletions protocol/direct/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package direct
import (
"os"

"github.com/withmandala/go-log"
"github.com/p4gefau1t/trojan-go/log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)
4 changes: 2 additions & 2 deletions protocol/mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/conf"
"github.com/p4gefau1t/trojan-go/log"
"github.com/p4gefau1t/trojan-go/protocol"
"github.com/p4gefau1t/trojan-go/stat"
"github.com/withmandala/go-log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

type MuxConnSession struct {
protocol.ConnSession
Expand Down
5 changes: 2 additions & 3 deletions protocol/nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"os"
"unsafe"

"github.com/withmandala/go-log"

"github.com/p4gefau1t/trojan-go/log"
syscall "golang.org/x/sys/unix"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

const (
IP6T_SO_ORIGINAL_DST = 80
Expand Down
4 changes: 2 additions & 2 deletions protocol/trojan/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package trojan
import (
"os"

"github.com/withmandala/go-log"
"github.com/p4gefau1t/trojan-go/log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)
5 changes: 2 additions & 3 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"io"
"os"

"github.com/withmandala/go-log"

"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/conf"
"github.com/p4gefau1t/trojan-go/log"
"github.com/p4gefau1t/trojan-go/protocol"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

func copyConn(dst io.Writer, src io.Reader, errChan chan error) {
_, err := io.Copy(dst, src)
Expand Down
4 changes: 2 additions & 2 deletions stat/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"io"
"os"

"github.com/withmandala/go-log"
"github.com/p4gefau1t/trojan-go/log"
)

var logger = log.New(os.Stdout).WithColor()
var logger = log.New(os.Stdout)

type TrafficMeter interface {
Count(passwordHash string, sent int, recv int)
Expand Down
2 changes: 1 addition & 1 deletion test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"os"

"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/log"
"github.com/p4gefau1t/trojan-go/protocol"
"github.com/withmandala/go-log"
)

var logger = log.New(os.Stdout)
Expand Down

0 comments on commit 60d6f33

Please sign in to comment.