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 skywire-cli proxy command #1680

Conversation

mrpalide
Copy link
Contributor

@mrpalide mrpalide commented Nov 24, 2023

Did you run make format && make check? Yes

Fixes #1675 #1682

Changes:

  • reimplement skywire-cli proxy status output
  • improve skywire-cli proxy stop command by add two flags --all and --name
  • reimplementation skywire-cli proxy start command
  • add ctrl+c signal to skywire-cli proxy start and skywire-cli vpn start commands

How to test this PR:

  • build skywire at this branch and run a visor
  • run skywire-cli proxy status for check status of proxies that available in skywire-config.json file
  • run proxy and check status command again
  • add new custom proxy to config like this: skywire-cli proxy start --name uk-proxy --pk 0216f90f998b11e83b0fa8eb76e5ba03c5dd72ab68432264f37e282f704992cd9f --addr :9090. By this command, we trying to add new custom proxy named uk-proxy with -srv flag as PubKey we use here 0216... and -addr flag as port available for proxy 127.0.0.1. Check status of proxies by skywire-cli proxy status again after running custom proxy.
  • skywire-cli proxy stop --name uk-proxy will stop uk-proxy. If you want stop all running proxies use --all flag as skywire-cli proxy stop --all
  • use arbitrary PK and start proxy or vpn, then trying ctrl+c shutdown signal shortcut.

@mrpalide mrpalide marked this pull request as ready for review November 29, 2023 02:01
@mrpalide mrpalide changed the title [WIP] improve skywire-cli proxy command improve skywire-cli proxy command Nov 29, 2023
@0pcom
Copy link
Collaborator

0pcom commented Dec 10, 2023

$ git clone https://github.com/mrpalide/skywire
Cloning into 'skywire'...
remote: Enumerating objects: 71769, done.
remote: Counting objects: 100% (4658/4658), done.
remote: Compressing objects: 100% (2561/2561), done.
Receiving objects:  91% (65458/71769), 37.00 MiB | 1.91 MiB/s/s
remote: Total 71769 (delta 1958), reused 4421 (delta 1859), pack-reused 67111
Receiving objects: 100% (71769/71769), 64.03 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (45034/45034), done.
$ cd skywire
$ git checkout feat/add-multiple-proxy-command-to-skywire-cli-proxy
branch 'feat/add-multiple-proxy-command-to-skywire-cli-proxy' set up to track 'origin/feat/add-multiple-proxy-command-to-skywire-cli-proxy'.
Switched to a new branch 'feat/add-multiple-proxy-command-to-skywire-cli-proxy'
$ sudo go run cmd/skywire-visor/skywire-visor.go -p --loglvl debug
...
$ skywire-cli proxy status
stopped
$ skywire-cli proxy list
03483a9eb478af76ecae7d0256118a1e2fac8c799f9fd51aebf92b1f8f96edf1c5:3 | ID
03894b70efab29edcb5669cda5c34e47a6efce9130849faeaac4c3776e69d7b152:3 | ID
03a934a4d3780ba3c9d91619faa36153041373bd6ce4ea57b0e9aeceb7f6771940:3 | SE
02071414e3ed2e595a70a414e05c6d9836a6d1d94793ededaa3bb248bfaf79d236:3 | ID
031e98c8306c98ad478bd45defbc84e2199b2a29fabc296609bd1e4a0e7d2c6e5e:3 | ID
039f7fb8e491aac08411ace482da85ba0147d13ca73d9b86f8c50f84c4fb812230:3 | ID
...
$ skywire-cli proxy start 0250e4d1b39a0360fb5d888324b8062bf57198a6fa5d7dda943b682652870b0a43
Starting...............................................
Running!
$ skywire-cli proxy status
running
$ go run cmd/skywire-cli/skywire-cli.go proxy start --pk 02bb45a0619f21fdee58a917032e36b6151e019388cbc4e5252f25bc2601f80994 --name us-proxy --addr :1081
Starting..
Running!
$ go run cmd/skywire-cli/skywire-cli.go proxy status
---- All Proxy List -----------------------------------------------------

Name: skysocks-client
Status: running
Server: 0250e4d1b39a0360fb5d888324b8062bf57198a6fa5d7dda943b682652870b0a43
Address: 
AppPort: 13
AutoStart: false

Name: us-proxy
Status: running
Server: 02bb45a0619f21fdee58a917032e36b6151e019388cbc4e5252f25bc2601f80994
Address: 127.0.0.1:1081
AppPort: 51
AutoStart: false

-------------------------------------------------------------------------
$ go run cmd/skywire-cli/skywire-cli.go proxy status --json
{
  "output": [
    {
      "name": "skysocks-client",
      "status": "running",
      "autostart": false,
      "args": [
        "-srv",
        "0250e4d1b39a0360fb5d888324b8062bf57198a6fa5d7dda943b682652870b0a43"
      ],
      "app_port": 13
    },
    {
      "name": "us-proxy",
      "status": "running",
      "autostart": false,
      "args": [
        "-srv",
        "02bb45a0619f21fdee58a917032e36b6151e019388cbc4e5252f25bc2601f80994",
        "-addr",
        ":1081"
      ],
      "app_port": 51
    }
  ]
}

$ curl -Lx socks5://127.0.0.1:1081 http://ip.skycoin.com/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     5  100     5    0     0      6      0 --:--:-- --:--:-- --:--:--     6
100   302  100   302    0     0    150      0  0:00:02  0:00:02 --:--:--   843
{
  "ip_address": "98.211.135.222",
  "latitude": 26.6165,
  "longitude": -80.0444,
  "postal_code": "33460",
  "continent_code": "NA",
  "country_code": "US",
  "country_name": "United States",
  "region_code": "FL",
  "region_name": "Florida",
  "province_code": "",
  "province_name": "",
  "city_name": "Lake Worth",
  "timezone": "America/New_York"
}
$ curl -Lx socks5://127.0.0.1:1080 http://ip.skycoin.com/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     5  100     5    0     0      3      0  0:00:01  0:00:01 --:--:--     3
100   302  100   302    0     0     80      0  0:00:03  0:00:03 --:--:--   151
{
  "ip_address": "208.78.41.141",
  "latitude": 49.2825,
  "longitude": -123.1291,
  "postal_code": "V6E",
  "continent_code": "NA",
  "country_code": "CA",
  "country_name": "Canada",
  "region_code": "BC",
  "region_name": "British Columbia",
  "province_code": "",
  "province_name": "",
  "city_name": "Vancouver",
  "timezone": "America/Vancouver"
}

$ go run cmd/skywire-cli/skywire-cli.go proxy stop --all
all skysocks clients stopped
$ go run cmd/skywire-cli/skywire-cli.go proxy status
---- All Proxy List -----------------------------------------------------

Name: skysocks-client
Status: stopped
Server: 0250e4d1b39a0360fb5d888324b8062bf57198a6fa5d7dda943b682652870b0a43
Address: 
AppPort: 13
AutoStart: false

Name: us-proxy
Status: stopped
Server: 02bb45a0619f21fdee58a917032e36b6151e019388cbc4e5252f25bc2601f80994
Address: 127.0.0.1:1081
AppPort: 51
AutoStart: false

-------------------------------------------------------------------------

Works great! Tremendous work, and something we really needed.

I will update the proxy documentation with this once merged, Thanks so much @mrpalide!

@0pcom 0pcom merged commit dc8d582 into skycoin:develop Dec 10, 2023
3 checks passed
@mrpalide mrpalide deleted the feat/add-multiple-proxy-command-to-skywire-cli-proxy branch March 26, 2024 13:51
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.

2 participants