Skip to content

Commit 44e8319

Browse files
authored
Merge pull request #18 from tonutils/test
ANDL&RLDP improvements and fixes & more debug info
2 parents 489ae12 + ffb13d9 commit 44e8319

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

cmd/proxy/main.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ton-utils/reverse-proxy/config"
1414
"github.com/xssnick/tonutils-go/adnl"
1515
"github.com/xssnick/tonutils-go/adnl/dht"
16+
"github.com/xssnick/tonutils-go/adnl/rldp"
1617
rldphttp "github.com/xssnick/tonutils-go/adnl/rldp/http"
1718
"github.com/xssnick/tonutils-go/liteclient"
1819
"github.com/xssnick/tonutils-go/tlb"
@@ -46,6 +47,14 @@ type Handler struct {
4647
}
4748

4849
func (h Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
50+
if *FlagDebug {
51+
reqDump, err := httputil.DumpRequestOut(request, true)
52+
if err != nil {
53+
return
54+
}
55+
fmt.Println("REQUEST:", string(reqDump))
56+
}
57+
4958
hdr := http.Header{}
5059
for k := range request.Header {
5160
// make headers canonical
@@ -57,7 +66,7 @@ func (h Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
5766

5867
log.Println("request:", request.Method, request.Host, request.RequestURI)
5968

60-
writer.Header().Set("Ton-Reverse-Proxy", "Tonutils Reverse Proxy v0.3.1")
69+
writer.Header().Set("Ton-Reverse-Proxy", "Tonutils Reverse Proxy v0.3.2")
6170
h.h.ServeHTTP(writer, request)
6271
}
6372

@@ -112,7 +121,11 @@ func main() {
112121

113122
if *FlagDebug == false {
114123
adnl.Logger = func(v ...any) {}
115-
// rldphttp.Logger = func(v ...any) {}
124+
rldphttp.Logger = func(v ...any) {}
125+
} else {
126+
rldp.Logger = log.Println
127+
rldphttp.Logger = log.Println
128+
adnl.Logger = log.Println
116129
}
117130

118131
proxy := httputil.NewSingleHostReverseProxy(u)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/mdp/qrterminal/v3 v3.0.0
77
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3
8-
github.com/xssnick/tonutils-go v1.9.9-0.20240726185310-b76c122b8cd6
8+
github.com/xssnick/tonutils-go v1.9.9-0.20240729172752-0ce0d252a288
99
)
1010

1111
require (

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ github.com/xssnick/tonutils-go v1.9.2 h1:70s1oqcJ4jOOmqjSik0TmZR05JySfk/PeVuPeXm
1313
github.com/xssnick/tonutils-go v1.9.2/go.mod h1:p1l1Bxdv9sz6x2jfbuGQUGJn6g5cqg7xsTp8rBHFoJY=
1414
github.com/xssnick/tonutils-go v1.9.9-0.20240726185310-b76c122b8cd6 h1:po4uMNWZTLZxO0Xms4BEHB8TCar3gLFMUAGgmvDsN9E=
1515
github.com/xssnick/tonutils-go v1.9.9-0.20240726185310-b76c122b8cd6/go.mod h1:p1l1Bxdv9sz6x2jfbuGQUGJn6g5cqg7xsTp8rBHFoJY=
16+
github.com/xssnick/tonutils-go v1.9.9-0.20240729172752-0ce0d252a288 h1:nbTy2yUnRob4iCjiQcJ8gQVoc6rtqgIVNKMnl5AvhRo=
17+
github.com/xssnick/tonutils-go v1.9.9-0.20240729172752-0ce0d252a288/go.mod h1:p1l1Bxdv9sz6x2jfbuGQUGJn6g5cqg7xsTp8rBHFoJY=
1618
github.com/xssnick/tonutils-go v1.9.9 h1:J0hVJI4LNEFHqgRHzpWTjFuv/Ga89OqLRUc9gxmjCoc=
1719
github.com/xssnick/tonutils-go v1.9.9/go.mod h1:p1l1Bxdv9sz6x2jfbuGQUGJn6g5cqg7xsTp8rBHFoJY=
1820
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=

0 commit comments

Comments
 (0)