Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed May 10, 2020
1 parent 468c283 commit 50db37d
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 60 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ Trojan-Go支持并且兼容原版Trojan-GFW的绝大多数功能,包括但不

### 移植性

运行Trojan-Go的可执行文件不依赖其他组件。你可以将编译得到的单个可执行文件在目标机器上直接执行而不需要考虑依赖的问题。你可以很方便地编译(或者交叉编译)它,然后在你的服务器,PC,树莓派,甚至路由器上部署。
运行Trojan-Go的可执行文件不依赖其他组件。你可以将编译得到的单个可执行文件在目标机器上直接执行而不需要考虑依赖的问题。你可以很方便地编译(或者交叉编译)它,然后在你的服务器,PC,树莓派,甚至路由器上部署。同时,可以方便地使用build tag删减各模块,以缩小可执行文件体积。

例如,交叉编译一个在mips处理器,linux操作系统上运行的,只有客户端功能的Trojan-Go,只需执行下面的命令即可

```shell
CGO_ENABLE=0 GOOS=linux GOARCH=mips go build -tags "client"
```

完整的说明参见[Trojan-Go 文档](https://p4gefau1t.github.io/trojan-go)。

### 易用

Expand Down
2 changes: 1 addition & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const (
Version = "v0.4.7"
Version = "v0.4.8"
)

type Runnable interface {
Expand Down
54 changes: 27 additions & 27 deletions conf/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,41 +206,41 @@ func loadClientConfig(config *GlobalConfig) error {
}
if config.TLS.CertPath == "" {
log.Info("cert of the remote server is not specified, using default CA list")
return nil
}

caCertByte, err := ioutil.ReadFile(config.TLS.CertPath)
if err != nil {
return common.NewError("failed to load cert file").Base(err)
}
pool := x509.NewCertPool()
ok := pool.AppendCertsFromPEM(caCertByte)
if !ok {
log.Warn("invalid CA cert list")
}
log.Info("using custom CA list")
pemCerts := caCertByte
for len(pemCerts) > 0 {
config.TLS.CertPool = pool
var block *pem.Block
block, pemCerts = pem.Decode(pemCerts)
if block == nil {
break
} else {
caCertByte, err := ioutil.ReadFile(config.TLS.CertPath)
if err != nil {
return common.NewError("failed to load cert file").Base(err)
}
if block.Type != "CERTIFICATE" || len(block.Headers) != 0 {
continue
pool := x509.NewCertPool()
ok := pool.AppendCertsFromPEM(caCertByte)
if !ok {
log.Warn("invalid CA cert list")
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
continue
log.Info("using custom CA list")
pemCerts := caCertByte
for len(pemCerts) > 0 {
config.TLS.CertPool = pool
var block *pem.Block
block, pemCerts = pem.Decode(pemCerts)
if block == nil {
break
}
if block.Type != "CERTIFICATE" || len(block.Headers) != 0 {
continue
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
continue
}
log.Trace("issuer:", cert.Issuer, "subject:", cert.Subject)
}
log.Debug("issuer:", cert.Issuer, ", subject:", cert.Subject)
}

//forward proxy settings
if config.ForwardProxy.Enabled {
log.Info("forward proxy enabled")
config.ForwardProxy.ProxyAddress = common.NewAddress(config.ForwardProxy.ProxyHost, config.ForwardProxy.ProxyPort, "tcp")
log.Info("forward proxy enabled:", config.ForwardProxy.ProxyAddress.String())
log.Debug("forward proxy:", config.ForwardProxy.ProxyAddress.String())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enableMissingTranslationPlaceholders = false
# Source Code repository section
description = "An unidentifiable mechanism that helps you bypass GFW. "
github_repository = "https://github.com/p4gefau1t/trojan-go"
version = "0.4.7"
version = "0.4.8"

# Documentation repository section
# documentation repository (set edit link to documentation repository)
Expand Down
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ go 1.14

require (
github.com/LiamHaworth/go-tproxy v0.0.0-20190726054950-ef7efd7f24ed
github.com/cenkalti/backoff/v4 v4.0.2 // indirect
github.com/go-acme/lego/v3 v3.5.0
github.com/go-sql-driver/mysql v1.5.0
github.com/golang/protobuf v1.4.0
github.com/golang/protobuf v1.4.1
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/mediocregopher/radix/v3 v3.5.0
github.com/miekg/dns v1.1.29 // indirect
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand All @@ -17,13 +19,15 @@ require (
github.com/smartystreets/goconvey v1.6.4
github.com/xtaci/smux v1.5.12
github.com/ziutek/mymysql v1.5.4 // indirect
go.starlark.net v0.0.0-20200330013621-be5394c419b6 // indirect
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1
google.golang.org/genproto v0.0.0-20200507105951-43844f6eee31 // indirect
google.golang.org/grpc v1.29.1
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
v2ray.com/core v4.19.1+incompatible
)

Expand Down
Loading

0 comments on commit 50db37d

Please sign in to comment.