Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dmsgweb #266

Merged
merged 15 commits into from
Jun 22, 2024
Merged

Improve dmsgweb #266

merged 15 commits into from
Jun 22, 2024

Conversation

0pcom
Copy link
Collaborator

@0pcom 0pcom commented Jun 13, 2024

  • make dmsg web srv able to proxy multiple ports over dmsg from the same public key.
  • remove redundant serve back to local port

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
Copy link
Collaborator Author

0pcom commented Jun 22, 2024

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.

@0pcom 0pcom merged commit 39e439d into skycoin:develop Jun 22, 2024
3 checks passed
@0pcom 0pcom deleted the dmsgweb-improve branch June 26, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant