@qpjoy/tunnel-cli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,19 +17,23 @@ Run commands directly through the bundled script:
17
17
 
18
18
  ```bash
19
19
  qp-tunnel-cli status
20
- qp-tunnel-cli tun-on
21
- qp-tunnel-cli tun-off
20
+ qp-tunnel-cli server-on
22
21
  qp-tunnel-cli update-subscription
23
22
  ```
24
23
 
25
24
  For server commands, `qp-tunnel-cli` re-runs itself with `sudo` when root is needed.
25
+ Use `server-on` for public VPS hosts: it keeps Mihomo running as a local outbound
26
+ proxy and configures shell, SSH, Docker/containerd/buildkit proxy drop-ins without
27
+ enabling TUN route takeover. Reserve `tun-on` for machines that are not serving
28
+ public inbound traffic.
26
29
 
27
30
  Install the bundled script as a normal Linux command:
28
31
 
29
32
  ```bash
30
33
  sudo qp-tunnel-cli install-script
34
+ sudo qp-tunnel-cli upgrade-systemd
31
35
  sudo mihomo-client status
32
- sudo mihomo-client tun-on
36
+ sudo mihomo-client server-on
33
37
  ```
34
38
 
35
39
  Use a custom target when needed:
package/dist/index.js CHANGED
@@ -21,6 +21,11 @@ const clientCommands = new Set([
21
21
  'logs',
22
22
  'enable',
23
23
  'disable',
24
+ 'upgrade-systemd',
25
+ 'server-on',
26
+ 'server-off',
27
+ 'egress-on',
28
+ 'egress-off',
24
29
  'proxy-on',
25
30
  'proxy-off',
26
31
  'tun-on',
@@ -50,6 +55,7 @@ Common commands:
50
55
  qp-tunnel-cli install --url http://IP:3434/peer_user01.mihomo.yaml --user download --password pass
51
56
  qp-tunnel-cli status
52
57
  qp-tunnel-cli start
58
+ qp-tunnel-cli server-on
53
59
  qp-tunnel-cli tun-on
54
60
  qp-tunnel-cli tun-off
55
61
  qp-tunnel-cli update-subscription
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qpjoy/tunnel-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Global QPJoy Tunnel CLI for installing and running the Linux mihomo-client script.",
5
5
  "private": false,
6
6
  "type": "commonjs",
@@ -16,6 +16,7 @@ MIHOMO_SERVICE_FILE="${MIHOMO_SERVICE_FILE:-/etc/systemd/system/$MIHOMO_SERVICE_
16
16
  MIHOMO_PROFILE_PROXY_FILE="${MIHOMO_PROFILE_PROXY_FILE:-/etc/profile.d/mihomo-client-proxy.sh}"
17
17
  MIHOMO_DAEMON_PROXY_SERVICES="${MIHOMO_DAEMON_PROXY_SERVICES:-docker.service containerd.service buildkit.service}"
18
18
  MIHOMO_DAEMON_PROXY_DROPIN_NAME="${MIHOMO_DAEMON_PROXY_DROPIN_NAME:-mihomo-proxy.conf}"
19
+ MIHOMO_NO_PROXY="${MIHOMO_NO_PROXY:-localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,100.88.0.0/16,100.89.0.0/16,100.90.0.0/16,host.docker.internal,.local}"
19
20
  MIHOMO_SSH_PROXY_HELPER="${MIHOMO_SSH_PROXY_HELPER:-/usr/local/bin/mihomo-ssh-proxy}"
20
21
  MIHOMO_SSH_CONFIG_DIR="${MIHOMO_SSH_CONFIG_DIR:-/etc/ssh/ssh_config.d}"
21
22
  MIHOMO_SSH_CONFIG_FILE="${MIHOMO_SSH_CONFIG_FILE:-$MIHOMO_SSH_CONFIG_DIR/99-mihomo-proxy.conf}"
@@ -41,6 +42,11 @@ Commands:
41
42
  logs Show recent service logs
42
43
  enable Enable service on boot
43
44
  disable Disable service on boot
45
+ upgrade-systemd Refresh the installed systemd unit from this script
46
+ server-on Enable persistent server-safe outbound proxy mode, without TUN
47
+ server-off Disable server-safe proxy integrations, keeping the service installed
48
+ egress-on Alias for server-on
49
+ egress-off Alias for server-off
44
50
  proxy-on Write /etc/profile.d proxy exports for login shells
45
51
  proxy-off Remove /etc/profile.d proxy exports
46
52
  tun-on Enable Mihomo TUN mode and also turn proxy-on on
@@ -85,6 +91,7 @@ Examples:
85
91
 
86
92
  sudo bash ./scripts/mihomo-client.sh update-subscription
87
93
  sudo bash ./scripts/mihomo-client.sh start
94
+ sudo bash ./scripts/mihomo-client.sh server-on
88
95
  sudo bash ./scripts/mihomo-client.sh proxy-on
89
96
  sudo bash ./scripts/mihomo-client.sh tun-on
90
97
  sudo bash ./scripts/mihomo-client.sh ssh-proxy-on
@@ -589,6 +596,7 @@ status_command() {
589
596
  echo "TUN mode: $([[ -f "$MIHOMO_TUN_OVERLAY_FILE" ]] && echo enabled || echo disabled)"
590
597
  echo "SSH proxy config: $([[ -f "$MIHOMO_SSH_CONFIG_FILE" ]] && echo enabled || echo disabled)"
591
598
  echo "Managed daemon proxy services: ${daemon_services:-none}"
599
+ echo "NO_PROXY: $MIHOMO_NO_PROXY"
592
600
  echo
593
601
  systemctl status "$MIHOMO_SERVICE_NAME" --no-pager || true
594
602
  }
@@ -711,10 +719,10 @@ daemon_proxy_on_command() {
711
719
  [Service]
712
720
  Environment="HTTP_PROXY=http://127.0.0.1:$port"
713
721
  Environment="HTTPS_PROXY=http://127.0.0.1:$port"
714
- Environment="NO_PROXY=localhost,127.0.0.1,::1"
722
+ Environment="NO_PROXY=$MIHOMO_NO_PROXY"
715
723
  Environment="http_proxy=http://127.0.0.1:$port"
716
724
  Environment="https_proxy=http://127.0.0.1:$port"
717
- Environment="no_proxy=localhost,127.0.0.1,::1"
725
+ Environment="no_proxy=$MIHOMO_NO_PROXY"
718
726
  EOF
719
727
  done
720
728
  systemd_reload
@@ -771,6 +779,40 @@ tun_off_command() {
771
779
  fi
772
780
  }
773
781
 
782
+ server_on_command() {
783
+ local was_tun_enabled="false"
784
+ if tun_enabled; then
785
+ was_tun_enabled="true"
786
+ remove_tun_overlay
787
+ render_runtime_config
788
+ fi
789
+ if service_is_active; then
790
+ if [[ "$was_tun_enabled" == "true" ]]; then
791
+ systemctl restart "$MIHOMO_SERVICE_NAME"
792
+ fi
793
+ else
794
+ systemctl start "$MIHOMO_SERVICE_NAME"
795
+ fi
796
+ systemctl enable "$MIHOMO_SERVICE_NAME" >/dev/null 2>&1 || true
797
+ proxy_on_command
798
+ ssh_proxy_on_command
799
+ daemon_proxy_on_command
800
+ echo "Server-safe outbound proxy mode enabled."
801
+ echo "Mihomo stays resident as a local proxy; TUN mode is disabled so public inbound services keep their normal return path."
802
+ }
803
+
804
+ server_off_command() {
805
+ remove_tun_overlay
806
+ render_runtime_config
807
+ proxy_off_command
808
+ ssh_proxy_off_command
809
+ daemon_proxy_off_command
810
+ if service_is_active; then
811
+ systemctl restart "$MIHOMO_SERVICE_NAME"
812
+ fi
813
+ echo "Server-safe outbound proxy integrations disabled. Mihomo service remains installed."
814
+ }
815
+
774
816
  run_command() {
775
817
  local port
776
818
  [[ $# -gt 0 ]] || die "Usage: sudo bash ./scripts/mihomo-client.sh run <command> [args...]"
@@ -852,6 +894,23 @@ install_command() {
852
894
  fi
853
895
  }
854
896
 
897
+ upgrade_systemd_command() {
898
+ ensure_dirs
899
+ load_env
900
+ log "Installing current mihomo-client launcher"
901
+ install_client_launcher
902
+ log "Refreshing systemd service file"
903
+ write_service_file
904
+ systemd_reload
905
+ systemctl enable "$MIHOMO_SERVICE_NAME" >/dev/null 2>&1 || true
906
+ if service_is_active; then
907
+ systemctl restart "$MIHOMO_SERVICE_NAME"
908
+ echo "Mihomo client systemd unit updated and service restarted."
909
+ else
910
+ echo "Mihomo client systemd unit updated. Start it with: systemctl start $MIHOMO_SERVICE_NAME"
911
+ fi
912
+ }
913
+
855
914
  start_command() {
856
915
  systemctl start "$MIHOMO_SERVICE_NAME"
857
916
  }
@@ -972,6 +1031,15 @@ main() {
972
1031
  disable)
973
1032
  disable_command
974
1033
  ;;
1034
+ upgrade-systemd)
1035
+ upgrade_systemd_command
1036
+ ;;
1037
+ server-on|egress-on)
1038
+ server_on_command
1039
+ ;;
1040
+ server-off|egress-off)
1041
+ server_off_command
1042
+ ;;
975
1043
  proxy-on)
976
1044
  proxy_on_command
977
1045
  ;;