pufferffish / wireproxy

Wireguard client that exposes itself as a socks5 proxy
ISC License
4.11k stars 235 forks source link

How to run wireproxy silently in the background #19

Closed fscarmen closed 2 years ago

fscarmen commented 2 years ago

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 commented 2 years ago

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

fscarmen commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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