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

How to run wireproxy silently in the background #19

Closed
fscarmen opened this issue Mar 29, 2022 · 21 comments
Closed

How to run wireproxy silently in the background #19

fscarmen opened this issue Mar 29, 2022 · 21 comments

Comments

@fscarmen
Copy link
Contributor

fscarmen commented Mar 29, 2022

I run winproxy with the command nohup wireproxy /etc/wireguard/proxy.conf >/dev/null 2>&1 & .
I want to run it in Systemd. There is a problem. Stuck for a long time, eventually showing timeout.
I think it's caused by windproxy running in the foreground

[Unit]
Description=WireProxy for WARP
After=network.target
Wants=network.target
Documentation=https://github.com/octeep/wireproxy

[Service]
Type=forking
ExecStart=/usr/bin/wireproxy /etc/wireguard/proxy.conf
RemainAfterExit=yes
Restart=always

[Install]
WantedBy=multi-user.target
@pufferffish
Copy link
Owner

I don't use systemd so I can't test this out, but have you tried Type=simple instead of Type=forking?

@fscarmen
Copy link
Contributor Author

I think it would be best to add parameters to run in the background in next verion. For example

wireproxy /etc/wireguard/proxy.conf -d

Thank you!

@pufferffish
Copy link
Owner

I think it would be best to add parameters to run in the background in next verion. For example

wireproxy /etc/wireguard/proxy.conf -d

Thank you!

I'll address this in the first "official" release version of wireproxy. I think after getting feedbacks from different communities, the codebase is mature enough. I'm gonna rework the command line parsing part, add this feature, and bump the version to v1.0

@fscarmen
Copy link
Contributor Author

Glad to hear this exciting news.
Many WARP users have reported such a need.
I also hope the parameter to close wireproxy. Now I need to use kill -9 $(pgrep -f wireproxy), which seems rude and unprofessional.

@pufferffish
Copy link
Owner

Glad to hear this exciting news. Many WARP users have reported such a need. I also hope the parameter to close wireproxy. Now I need to use kill -9 $(pgrep -f wireproxy), which seems rude and unprofessional.

How exactly would the parameter closing wireproxy looks like? Would it be something like wireproxy --close? I am not sure how that work with multiple instances of wireproxy.

@fscarmen
Copy link
Contributor Author

How abt like screen?

case 1: one session

[root@srv21706 ~]# screen -SX a quit
[root@srv21706 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -ls
There is a screen on:
        11609.a (Detached)
1 Socket in /var/run/screen/S-root.

[root@srv21706 ~]# screen -SX a quit
[root@srv21706 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

case 2: multiple sessions

[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -ls
There are screens on:
        12705.a (Detached)
        12676.a (Detached)
        12631.a (Detached)
3 Sockets in /var/run/screen/S-root.

[root@srv21706 ~]# screen -SX 12705 quit
[root@srv21706 ~]# screen -ls
There are screens on:
        12676.a (Detached)
        12631.a (Detached)
2 Sockets in /var/run/screen/S-root.

[root@srv21706 ~]# screen -SX 12631.a quit
[root@srv21706 ~]# screen -ls
There is a screen on:
        12676.a (Detached)
1 Socket in /var/run/screen/S-root.

@pufferffish
Copy link
Owner

Ah, so each instance of wireproxy is named and you can close them by specifying the name of the instance of the wireproxy you want to close. I think we can do that. This also ties in to one of the task in #16 too. I will address this in the future.

@fscarmen
Copy link
Contributor Author

yes if there is one session . It can be closed by name. And if more than 1 session which is named the same. It will hint you to specify

[root@srv21706 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -USdm a
[root@srv21706 ~]# screen -ls
There are screens on:
        24870.a (Detached)
        24841.a (Detached)
2 Sockets in /var/run/screen/S-root.

[root@srv21706 ~]# screen -SX a quit
There are several suitable screens on:
        24870.a (Detached)
        24841.a (Detached)
Use -S to specify a session.
[root@srv21706 ~]# screen -SX 24870 quit
[root@srv21706 ~]# screen -ls
There is a screen on:
        24841.a (Detached)
1 Socket in /var/run/screen/S-root.

[root@srv21706 ~]# screen -SX a quit
[root@srv21706 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

@pufferffish
Copy link
Owner

I think it would be best to add parameters to run in the background in next verion. For example

wireproxy /etc/wireguard/proxy.conf -d

Thank you!

Daemon flag has been implemented in the latest commit, note that there is also a slight change to how the path of the configuration is passed to wireproxy as well. I've tested the daemon feature on my OpenBSD and Linux machines. Can you confirm that it works for you as well?

@pufferffish
Copy link
Owner

pufferffish commented Mar 30, 2022

@fscarmen also did you manage to get wireproxy working with cloudflare warp? I'm interested in using it as well.

Edit: nvm got it working

@ElDavoo
Copy link

ElDavoo commented Mar 30, 2022

@fscarmen also did you manage to get wireproxy working with cloudflare warp? I'm interested in using it as well.

Edit: nvm got it working

As a bit of off-topic discussion: I wanted to make it working for torrenting, but doesn't look like it works :( the only thing that is working is HTTP tracker updates

@fscarmen
Copy link
Contributor Author

Can you confirm that it works for you as well?

Quite practical, now I use systemctl restart wgcf to restart the warp service to indirectly change the warp ip to unlock Netflix.

@fscarmen
Copy link
Contributor Author

fscarmen commented Mar 30, 2022

@fscarmen also did you manage to get wireproxy working with cloudflare warp? I'm interested in using it as well.

Edit: nvm got it working

Yes.I will do deeper integration in existing projects.
image

image

@pufferffish
Copy link
Owner

@fscarmen also did you manage to get wireproxy working with cloudflare warp? I'm interested in using it as well.
Edit: nvm got it working

As a bit of off-topic discussion: I wanted to make it working for torrenting, but doesn't look like it works :( the only thing that is working is HTTP tracker updates

What client are you using?

@fscarmen
Copy link
Contributor Author

Do you mean by CloudFlare WARP Client for Linux?
https://blog.cloudflare.com/announcing-warp-for-linux-and-proxy-mode

Tonight I will add wireproxy options to the menu.

@pufferffish
Copy link
Owner

Do you mean by CloudFlare WARP Client for Linux? https://blog.cloudflare.com/announcing-warp-for-linux-and-proxy-mode

Tonight I will add wireproxy options to the menu.

Ah I was replying to @ElDavoo, asking what torrent client he's using. This issue has too many off topic discussion right now. I'll close it and split it to two different issues.

@fscarmen
Copy link
Contributor Author

fscarmen commented Mar 31, 2022

I don't use systemd so I can't test this out, but have you tried Type=simple instead of Type=forking?

It works. Ths.
'Type=simple' is default, so i remove it.
Now the systemd file content is as follow. ( /usr/lib/systemd/system/wireproxy.service )

[Unit]
Description=WireProxy for WARP
After=network.target
Documentation=https://github.com/fscarmen/warp
Documentation=https://github.com/octeep/wireproxy
[Service]
ExecStart=/usr/bin/wireproxy /etc/wireguard/proxy.conf
RemainAfterExit=yes
Restart=always
[Install]
WantedBy=multi-user.target

I turn on the WireProxy service by systemctl start wireproxy
turn it off by systemctl stop wireproxy
change the warp ip (restart service) by systemctl restart wireproxy
enable daemon systemctl enable --now wireproxy
disable daemon systemctl disable --now wireproxy

@pufferffish
Copy link
Owner

I don't use systemd so I can't test this out, but have you tried Type=simple instead of Type=forking?

It works. Ths. 'Type=simple' is default, so i remove it. Now the systemd file content is as follow. ( /usr/lib/systemd/system/wireproxy.service )

[Unit]
Description=WireProxy for WARP
After=network.target
Documentation=https://github.com/fscarmen/warp
Documentation=https://github.com/octeep/wireproxy
[Service]
ExecStart=/usr/bin/wireproxy /etc/wireguard/proxy.conf
RemainAfterExit=yes
Restart=always
[Install]
WantedBy=multi-user.target

I turn on the WireProxy service by systemctl enable --now wireproxy turn it off by systemctl disable --now wireproxy change the warp ip (restart service) by systemctl restart wireproxy

Are you using the latest version? It should be ExecStart=/usr/bin/wireproxy -c /etc/wireguard/proxy.conf.

@fscarmen
Copy link
Contributor Author

Are you using the latest version? It should be ExecStart=/usr/bin/wireproxy -c /etc/wireguard/proxy.conf.

Not yet. I fail to cross compile wireproxy in action. The previous version was ok. I guess there is no file: main.go

@pufferffish
Copy link
Owner

pufferffish commented Mar 31, 2022

Are you using the latest version? It should be ExecStart=/usr/bin/wireproxy -c /etc/wireguard/proxy.conf.

Not yet. I fail to cross compile wireproxy in action. The previous version was ok. I guess there is no file: main.go

Ah yes, you should compile with this command: go build ./cmd/wireproxy instead. I will add an instruction in README. Alternatively, you can find it on the Actions tab. I setup a CI to build it for every commits.

Here is the binaries for the latest commit https://github.com/octeep/wireproxy/actions/runs/2068821766

@pufferffish
Copy link
Owner

@fscarmen do you mind moving this conversation to discussion? I don't think it's appropiate to discuss on an issue tracker. https://github.com/octeep/wireproxy/discussions/25

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

3 participants