skycoin / dmsg

dmsg
7 stars 17 forks source link

Improve `dmsgweb` #266

Closed 0pcom closed 5 months ago

0pcom commented 5 months ago

Testing

for the convenience of a one-liner, ncat (from nmap) is used for this demonstration

terminal 1:

while true; do echo -e "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World" | ncat -l -p 8000; done

terminal 2:

while true; do echo -e "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World" | ncat -l -p 8002; done

terminal 3:

$ go run cmd/dmsg/dmsg.go web srv -l 8000,8002 -d 8000,8002 -e 2
[2024-06-13T11:08:01.12601896-05:00] DEBUG disc.NewHTTP [dmsgwebsrv]: Created HTTP client. addr="http://dmsgd.skywire.skycoin.com"
[2024-06-13T11:08:01.126143362-05:00] DEBUG [dmsg_client]: Discovering dmsg servers...
[2024-06-13T11:08:01.615859419-05:00] DEBUG [dmsg_client]: Dialing session... remote_pk=02a2d4c346dabd165fd555dfdba4a7f4d18786fe7e055e562397cd5102bdd7f8dd
[2024-06-13T11:08:06.746701214-05:00] WARN [dmsg_client]: Failed to establish session. current_backoff="5s" error="deadline exceeded" remote_pk=02a2d4c346dabd165fd555dfdba4a7f4d18786fe7e055e562397cd5102bdd7f8dd
[2024-06-13T11:08:11.75002747-05:00] DEBUG [dmsg_client]: Dialing session... remote_pk=0371ab4bcff7b121f4b91f6856d6740c6f9dc1fe716977850aeb5d84378b300a13
[2024-06-13T11:08:16.883395025-05:00] WARN [dmsg_client]: Failed to establish session. current_backoff="6.5s" error="deadline exceeded" remote_pk=0371ab4bcff7b121f4b91f6856d6740c6f9dc1fe716977850aeb5d84378b300a13
[2024-06-13T11:08:23.386686973-05:00] DEBUG [dmsg_client]: Dialing session... remote_pk=03d5b55d1133b26485c664cf8b95cff6746d1e321c34e48c9fed293eff0d6d49e5
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[2024-06-13T11:08:24.314259108-05:00] DEBUG [dmsg_client]: Serving session. remote_pk=03d5b55d1133b26485c664cf8b95cff6746d1e321c34e48c9fed293eff0d6d49e5
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] POST   /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] PUT    /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] GET    /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] POST   /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] PUT    /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] PATCH  /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] HEAD   /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] OPTIONS /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] DELETE /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] CONNECT /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] TRACE  /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[2024-06-13T11:08:24.314449423-05:00] INFO [dmsgwebsrv]: Serving on dmsg port 8002 with DMSG listener 02b2dfa5c192a413079437d2e5e810af69217ae10c2072b8af46015140e8bc7a8b:8002
[GIN-debug] PATCH  /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] HEAD   /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] OPTIONS /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] DELETE /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] CONNECT /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[GIN-debug] TRACE  /*path                    --> github.com/skycoin/dmsg/cmd/dmsgweb/commands.server.func3.1 (3 handlers)
[2024-06-13T11:08:24.314526001-05:00] INFO [dmsgwebsrv]: Serving on dmsg port 8000 with DMSG listener 02b2dfa5c192a413079437d2e5e810af69217ae10c2072b8af46015140e8bc7a8b:8000

terminal 4

$ go run cmd/dmsg/dmsg.go curl dmsg://02b2dfa5c192a413079437d2e5e810af69217ae10c2072b8af46015140e8bc7a8b:8000/
Hello World

$ go run cmd/dmsg/dmsg.go curl dmsg://02b2dfa5c192a413079437d2e5e810af69217ae10c2072b8af46015140e8bc7a8b:8002/
Hello World
0pcom commented 5 months ago

The current deployment outage makes this difficult to test. So this will be merged without a final test as it pertains to non-critical functionality, and any issues will be addressed in another PR when the dmsg deployment is operational once more.