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

Allow to change IPv4/v6 Prefix from environment variables #7

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

valentin2105
Copy link

@valentin2105 valentin2105 commented Feb 28, 2019

This PR include :

Change the IPv4/v6 Pool via environment variables :

  • SUBSPACE_IPV4_POOL
  • SUBSPACE_IPV6_POOL

Change the IPv4/v6 Gateway via environment variables :

( .1 or :1 is used by default if not present)

  • SUBSPACE_IPV4_GW
  • SUBSPACE_IPV4_GW

Enable or disable IPv6 NAT

  • SUBSPACE_IPV6_NAT_ENABLED (default 1)

Change the DNS Server via environement variable :

  • SUBSPACE_NAMESERVER (default 1.1.1.1)

Feel free to ask if any change is needed.

@Freekers
Copy link

I would love to see this merged!

@valentin2105
Copy link
Author

@Freekers , if you want to try it out, check this Docker image : valentinnc/subspace:latest or my repo https://github.com/valentin2105/subspace.

@Freekers
Copy link

@valentin2105 Wohoo that works perfectly! Thank you so much!

@Freekers
Copy link

@valentin2105 Can you please merge up to this commit in your repo? I need it to work with my reverse proxy: 502f0f5

A more recent commit is fine as well :)

Thank you very much!

@valentin2105
Copy link
Author

@Freekers can you try it from my repo ? I have merged master from subspace. (from Github UI so maybe it's broken).

Thanks. (ask if you want I update the docker Image)

@Freekers
Copy link

The Docker image has not been updated yet on Docker Hub if I'm not mistaken?
https://hub.docker.com/r/valentinnc/subspace

I will check back tomorrow :)

@Freekers
Copy link

@valentin2105 Something went wrong during the merge. In handlers.go, the struct got duplicated. I tried fixing it myself in addition to making the Listenport variable, but I didn't succeed.
The port changes correctly in the server.conf and Wireguard is listening on the correct Port now, but when generating the client conf, it always falls back to the default port.
Can you please help me?
https://github.com/Freekers/subspace/blob/master/handlers.go

Thank yoU!

@valentin2105
Copy link
Author

@Freekers I have fixed in my repo and Updated the docker image, it should be good ;)
FYI it was the Struct which need to respect the order of declaration and assignation of variable. It's fixed now.

@Freekers
Copy link

@valentin2105 Thank you very much! Your image is working for me now!
However, I'm still having issues getting my modification to work (i.e. allow changing the Listenport using an environmental variable). I just applied your commit to my repository as well, but Subspace keeps using the default port (51820) in the generated client conf files. The server confs are fine though... Can you spot the error in my handlers.go? https://github.com/Freekers/subspace/blob/master/handlers.go

Many thanks!!

Kind regards.

@valentin2105
Copy link
Author

@Freekers Your code seem fine,
Do you :

  • Compile well and use the good binary and not the old one present in the git..
  • Set the env variable to change the port in your docker container or Machine before launch the subspace binary ?

@Freekers
Copy link

Freekers commented Jun 12, 2019

@valentin2105 Thanks for your reply :)

  • Yes, I did a fresh pull of the repository and deleted the local docker image first before building a new one, just to make sure
  • Yes. I checked this by connecting to the container using bash and printing the env variable. It showed up correctly: https://i.imgur.com/MXlyzFs.png

@valentin2105
Copy link
Author

valentin2105 commented Jun 12, 2019

@Freekers Did you run :

go get -u github.com/jteeuwen/go-bindata/...
go-bindata --pkg main static/... templates/... email/... 
go build 
rm subspace-linux-amd64
mv subspace  subspace-linux-amd64
docker build ... && docker push

@Freekers
Copy link

@valentin2105 Ah, no I didn't do that. Now I see what you mean by the old binary in git. I feel stupid now! Sorry about that.
Do I literally copy/paste and run your code snippet, or do I need to run more code than just that?

I have to go now, I'll check back tomorrow. Thanks for all your help so far!

@valentin2105
Copy link
Author

valentin2105 commented Jun 12, 2019

@Freekers , Don't feel stupid, there is no documentation at all in the repo.
You need to launch all this command in the subspace/ folder wherer you made your change.

If you want, I can add these modification in my repo, push it here and build my docker image with it, so You can test and confirm that it work ? :)
We can use this PR for that.
(hoping it will be merged anyday)

@Freekers
Copy link

Freekers commented Jun 13, 2019

Thanks for all your help!! I managed to recompile subspace's binary, rebuild the Docker and can now confirm that your and mine changes are working :)
I just opened a merge request to your fork, so that we have these features neatly integrated into the same fork and so that you can push the Docker image to Docker Hub for everyone to use :)
Then one day, indeed, we can hope it gets merged into master....

valentin2105#1

Kind regards.

@theogravity
Copy link

@valentin2105 thank you so much for your fork and docker hub image! saved me a ton of time doing it myself

@pupkarev
Copy link

pupkarev commented May 7, 2021

Hi. could you tell me how I can change default GW(i mean for client use Lan network and not 0.0.0.0/0). And I cant change the pool and have DNS uncorrected

docker create \
--name subspace \
--restart always \
--network host \
--cap-add NET_ADMIN \
--volume /data:/data \
--env SUBSPACE_HTTP_HOST="vpn.hostname" \
--env SUBSPACE_NAMESERVER="192.168.18.1" \
--env SUBSPACE_LISTENPORT="51821" \
--env SUBSPACE_IPV4_POOL="192.168.25.0/24" \
--env SUBSPACE_IPV4_GW="192.168.25.1" \
--env SUBSPACE_IPV6_NAT_ENABLED="0" \
subspacecommunity/subspace:latest

with the next setting for subspace, i have the next client config:


[Interface]
PrivateKey = DNS = 192.168.25.1, fd00::10:97:1
Address = 10.99.97.4/24,fd00::10:97:4/112

[Peer]
PublicKey = 
Endpoint = vpn.hostname:51821
AllowedIPs = 0.0.0.0/0, ::/0

I want to have next client config

[Interface]
PrivateKey = DNS = 192.168.18.1
Address = 192.168.25.3

[Peer]
PublicKey = 
Endpoint = vpn.hostname:51821
AllowedIPs = 192.168.18.0.24

i.e. want to only access to LAN. and next steps create SSO. thanks

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.

4 participants