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

Building holepunch client #10

Closed
develamit opened this issue May 27, 2020 · 4 comments
Closed

Building holepunch client #10

develamit opened this issue May 27, 2020 · 4 comments

Comments

@develamit
Copy link

Hi joonas-fi,
I am new to this and I am trying to build and use your code by following the README. But I am falling short. Could you please update the README on how I can build holepunch client and execute it?

Also, if the remote server has the sshd running on a port other than 22, then how can I introduce custom port in the json file?

So far I have done this:

  1. Edited a file holepunch.json (similar to holepunch.example.json) and kept it in cmd/holepunch directory.
  2. Put an extra line: "port" : <custom_port_num> under "ssh_server": {...} since my ssh server uses a custom port for sshd and not the regular 22
  3. Invoked the command: go build main.go

But I am unable to make this work by following the README. I am getting errors.
Thanks,
-amit

@joonas-fi
Copy link
Member

Hi Amit, sorry you've had trouble.

Building

First off, I want to confirm that you really want to build it? There's ready-made releases for Windows, Linux (both amd64 and ARM for Raspberry Pi etc.)? If your platform (Mac?) is missing, I can add it.

If you really want to build it (maybe you want to hack on the code):

If you've installed the Turbo Bob util, then all you need to do is run $ bob build

If you prefer not to install Turbo Bob, then you need to have basic understanding of building Go-based projects. Once you've installed Go build tools ($ go version works), you can $ cd cmd/holepunch-client/ && go build. I tested building it just now in a Docker container:

$ docker run --rm -it golang:1.13.5-stretch
$ mkdir /project && cd /project
$ git clone https://github.com/function61/holepunch-client.git
$ cd holepunch-client/
$ cd cmd/holepunch/
$ go build

SSH port other than 22

You should just be able to set the port after the colon, see example config file. Sorry, the example was missing the port (I fixed it just now) which was super confusing - my bad. :(

Thanks for bringing this to my attention!

@develamit
Copy link
Author

Hi joonas-fi,
Thanks for your prompt response. Really appreciate it.

  1. port issue is now resolved. I tried the way you mentioned in holepunch.json and it worked
  2. Barebone build worked too. I am not using turbo bob and wanted to do native "go build". It works now
  3. I am successful in opening multiple connections, closing them and reopening them. It simply works.

Like you, I also got inspired by the work of codref (https://gist.github.com/codref/473351a24a3ef90162cf10857fac0ff3) and started tinkering around the code. But I wanted to be in a position to open multiple client connections and opening and closing them at will. I saw yours and wanted to use it. I will go over the "main.go" code really well and would try to understand every line, particularly the part which enables the multiple connections possible. If you get some time and add some documentation in the code then that would be great addition for people like me who gets inspired and try to use the awesome work like yours and 'coderefs'.

Would like to stay in touch with you.
Thanks,
Amit

@joonas-fi
Copy link
Member

Glad that took care of your problems :)

You're right, the code documentation could be improved on a bit. I added some comments here: 5681ff4

(I also split the code in a couple more files, but I didn't change functionality)

I didn't go crazy with my comments (too little time) - I only added comments to the most hairiest places.

This comment explains, why multiple connections work:

// handle the connection in another goroutine, so we can support multiple concurrent

Hope this helps, best luck :)

@develamit
Copy link
Author

Thanks much!
I will go over it thoroughly, now that it is much more readable. Appreciate it.
-amit

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

No branches or pull requests

2 participants