### Install NPS Server (Windows) Source: https://github.com/ehang-io/nps/blob/master/README.md Run this command in an administrator command prompt on Windows to install NPS as a system service. Navigate to the NPS installation directory first. ```bash nps.exe install ``` -------------------------------- ### Download and Install NPS Server Source: https://context7.com/ehang-io/nps/llms.txt Download the NPS server binary, extract it, and install it as a system service on your public-facing machine. Configuration file is located at /etc/nps/conf/nps.conf. ```bash # Download from releases wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz tar -xzf linux_amd64_server.tar.gz cd linux_amd64_server # Install as system service (Linux/macOS) sudo ./nps install # Start the server sudo nps start # Stop the server sudo nps stop # Check version ./nps -version # Configuration file location: /etc/nps/conf/nps.conf # Default web port: 8080 # Default bridge port: 8024 # Default credentials: admin/123 ``` -------------------------------- ### Download and Install NPS Client Source: https://context7.com/ehang-io/nps/llms.txt Download the NPC client binary, extract it, and connect to the NPS server. It can be run in no-config mode or installed as a system service. Configuration can also be managed via a config file. ```bash # Download from releases wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz tar -xzf linux_amd64_client.tar.gz cd linux_amd64_client # Connect to server (no config file mode) ./npc -server=1.1.1.1:8024 -vkey=your_client_vkey # Install as system service sudo ./npc install -server=1.1.1.1:8024 -vkey=your_client_vkey sudo npc start # Or use config file mode ./npc -config=/path/to/npc.conf ``` -------------------------------- ### Start NPS Server (Linux/macOS) Source: https://github.com/ehang-io/nps/blob/master/README.md Start the NPS server service on Linux or macOS. Administrator privileges are required. ```bash sudo nps start ``` -------------------------------- ### Install NPS as a System Service (Windows) Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Register the NPS client as a system service on Windows by running the command as an administrator. This enables automatic startup and daemonization. ```powershell npc.exe install 其他参数(例如-server=xx -vkey=xx或者-config=xxx) ``` -------------------------------- ### NPS HTTP Proxy Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for setting up an HTTP proxy. This allows NPS to act as an HTTP proxy, forwarding requests from a specified server port. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [http] mode=httpProxy server_port=9003 ``` -------------------------------- ### NPS Global Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Example of the global configuration section in an NPS configuration file. This section defines essential connection parameters and general settings. ```ini [common] server_addr=1.1.1.1:8024 conn_type=tcp vkey=123 username=111 password=222 compress=true crypt=true rate_limit=10000 flow_limit=100 remark=test max_conn=10 #pprof_addr=0.0.0.0:9999 ``` -------------------------------- ### Start NPS Server (Windows) Source: https://github.com/ehang-io/nps/blob/master/README.md Start the NPS server service on Windows. Execute this command in an administrator command prompt from the NPS program directory. ```bash nps.exe start ``` -------------------------------- ### Install NPS Server (Linux/macOS) Source: https://github.com/ehang-io/nps/blob/master/README.md Execute this command on Linux or macOS to install NPS as a system service. Ensure you have administrator privileges. ```bash sudo ./nps install ``` -------------------------------- ### NPS Client Configuration Example Source: https://context7.com/ehang-io/nps/llms.txt Example configuration for the NPC client (npc.conf). This file defines common settings and various tunnel types like domain proxy, TCP, UDP, HTTP proxy, SOCKS5, secret, P2P, and file server. ```ini [common] server_addr=1.1.1.1:8024 conn_type=tcp vkey=your_client_vkey auto_reconnection=true max_conn=1000 flow_limit=1000 rate_limit=1000 compress=true crypt=true disconnect_timeout=60 # Optional: Connect through proxy # proxy_url=socks5://user:pass@127.0.0.1:1080 # Domain proxy (HTTP reverse proxy) [web1] host=app.example.com target_addr=127.0.0.1:8080,127.0.0.1:8081 host_change=www.internal.local header_set_proxy=nps # TCP tunnel (SSH access) [ssh_tunnel] mode=tcp target_addr=192.168.1.100:22 server_port=9022 # UDP tunnel (DNS forwarding) [dns_tunnel] mode=udp target_addr=192.168.1.1:53 server_port=5353 # HTTP proxy [http_proxy] mode=httpProxy server_port=8888 # SOCKS5 proxy [socks5_proxy] mode=socks5 server_port=1080 multi_account=multi_account.conf # Secret proxy (no exposed port) [secret_ssh] mode=secret password=unique_secret_key target_addr=192.168.1.100:22 # P2P tunnel (direct connection) [p2p_ssh] mode=p2p password=unique_p2p_key target_addr=192.168.1.100:22 # File server [file_server] mode=file server_port=9100 local_path=/var/www/files strip_pre=/files/ ``` -------------------------------- ### NPS Domain Proxy Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for setting up a domain proxy. This allows NPS to handle incoming HTTP/HTTPS requests for a specified domain and forward them to internal services. Load balancing is supported. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [web1] host=a.proxy.com target_addr=127.0.0.1:8080,127.0.0.1:8082 host_change=www.proxy.com header_set_proxy=nps ``` -------------------------------- ### NPS Server Configuration Example Source: https://context7.com/ehang-io/nps/llms.txt Example configuration for the NPS server (nps.conf). This file defines proxy ports, bridge settings, web interface, authentication, P2P settings, logging, and feature toggles. ```ini appname = nps runmode = pro # HTTP(S) proxy ports for domain resolution http_proxy_ip=0.0.0.0 http_proxy_port=80 https_proxy_port=443 https_just_proxy=true https_default_cert_file=conf/server.pem https_default_key_file=conf/server.key # Bridge settings (server-client communication) bridge_type=tcp bridge_port=8024 bridge_ip=0.0.0.0 # Public vkey for config file mode clients public_vkey=your_secret_key # Web management interface web_host=nps.example.com web_username=admin web_password=secure_password_here web_port=8080 web_ip=0.0.0.0 web_open_ssl=false # Web API authentication (16 chars required) auth_key=your_api_auth_key auth_crypt_key=1234567812345678 # P2P settings p2p_ip=1.1.1.1 p2p_port=6000 # Logging (0=Emergency to 7=Debug) log_level=3 # Feature toggles allow_user_login=false allow_user_register=false allow_flow_limit=true allow_rate_limit=true allow_tunnel_num_limit=true allow_local_proxy=false allow_connection_num_limit=true allow_multi_ip=false system_info_display=true # Port whitelist allow_ports=9001-9009,10001,11000-12000 # HTTP cache for static files http_cache=true http_cache_length=100 # Client disconnect timeout (unit: 5s, default 60 = 5 minutes) disconnect_timeout=60 ``` -------------------------------- ### Install NPS as a System Service (Linux/macOS) Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Register the NPS client as a system service for automatic startup and daemonization on Linux and macOS. Ensure you stop the client first if it's already running. ```bash sudo ./npc install 其他参数(例如-server=xx -vkey=xx或者-config=xxx) ``` -------------------------------- ### NPS SOCKS5 Proxy Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for setting up a SOCKS5 proxy. This allows NPS to act as a SOCKS5 proxy, forwarding requests from a specified server port. Multi-account support is available via a configuration file. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [socks5] mode=socks5 server_port=9004 multi_account=multi_account.conf ``` -------------------------------- ### NPS UDP Tunnel Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for establishing a UDP tunnel. This forwards UDP traffic from a specified server port to an internal target address. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [udp] mode=udp target_addr=127.0.0.1:8080 server_port=9002 ``` -------------------------------- ### Configure NPC via Environment Variables Source: https://context7.com/ehang-io/nps/llms.txt Use environment variables for configuration in containerized environments or automated setups. Supports direct execution or template-based config files. ```bash # No config file mode - set environment variables export NPC_SERVER_ADDR=1.1.1.1:8024 export NPC_SERVER_VKEY=your_secret_vkey # Simply run npc without arguments ./npc # Config file mode with environment variable templating cat > /etc/npc/npc.conf << 'EOF' [common] server_addr={{.NPC_SERVER_ADDR}} conn_type=tcp vkey={{.NPC_SERVER_VKEY}} auto_reconnection=true [web] host={{.NPC_WEB_HOST}} target_addr={{.NPC_WEB_TARGET}} EOF # Set the variables export NPC_SERVER_ADDR=1.1.1.1:8024 export NPC_SERVER_VKEY=abc123 export NPC_WEB_HOST=app.example.com export NPC_WEB_TARGET=127.0.0.1:8080 # Run with config file (variables auto-rendered) ./npc -config=/etc/npc/npc.conf # Docker example docker run -d --name npc --net=host \ -e NPC_SERVER_ADDR=1.1.1.1:8024 \ -e NPC_SERVER_VKEY=abc123 \ ffdfgdfg/npc ``` -------------------------------- ### Run NPS Client Without Configuration File Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Use this command to run the NPS client when all configurations are managed via the server's web interface. No additional client setup is required beyond this command. ```bash ./npc -server=ip:port -vkey=web界面中显示的密钥 ``` -------------------------------- ### NPS File Access Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for enabling file access mode, which exposes local files as a public service. This mode requires the client to be running in configuration file mode. It specifies the server port, local path, and a prefix for URL access. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [file] mode=file server_port=9100 local_path=/tmp/ strip_pre=/web/ ``` -------------------------------- ### NPS P2P Proxy Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for a peer-to-peer (P2P) proxy mode, also suitable for secure access like SSH. It uses a unique password for authentication and defines the internal target address. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [p2p_ssh] mode=p2p password=ssh2 target_addr=10.1.50.2:22 ``` -------------------------------- ### NPS TCP Tunnel Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for establishing a TCP tunnel. This forwards TCP traffic from a specified server port to an internal target address. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [tcp] mode=tcp target_addr=127.0.0.1:8080 server_port=9001 ``` -------------------------------- ### Run NPS Client With Configuration File Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Launch the NPS client using a specified configuration file. This mode allows for client-side configuration and management. ```bash ./npc -config=npc配置文件路径 ``` -------------------------------- ### Configure SOCKS5 Proxy with Authentication Source: https://context7.com/ehang-io/nps/llms.txt Set up a SOCKS5 proxy with authentication using a separate configuration file for user credentials. Update the main NPC config to reference the authentication file. ```bash # With authentication (multi_account.conf) cat > /etc/npc/multi_account.conf << 'EOF' user1:password1 user2:password2 EOF # Update npc.conf # multi_account=multi_account.conf curl --socks5 user1:password1@1.1.1.1:1080 http://internal-site.local ``` -------------------------------- ### Display Target String Source: https://github.com/ehang-io/nps/blob/master/web/views/index/hedit.html Placeholder to display the target string in the configuration. ```Go Template {{.h.Target.TargetStr}} ``` -------------------------------- ### Configure HTTP Proxy via Client Config File Source: https://context7.com/ehang-io/nps/llms.txt Set up an HTTP forward proxy using a client configuration file. This allows access to internal HTTP/HTTPS websites through the proxy. ```bash # Client config for HTTP proxy on port 8888 cat > /etc/npc/npc.conf << 'EOF' [common] server_addr=1.1.1.1:8024 vkey=abc123 [http_proxy] mode=httpProxy server_port=8888 EOF ./npc -config=/etc/npc/npc.conf ``` -------------------------------- ### Initialize Bootstrap Table for Client Management Source: https://github.com/ehang-io/nps/blob/master/web/views/client/list.html Configures the Bootstrap Table with server-side pagination, custom detail views, and column definitions for client data. ```javascript /*bootstrap table*/ $('#table').bootstrapTable({ toolbar: "#toolbar", method: 'post', // 服务器数据的请求方式 get or post url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址 contentType: "application/x-www-form-urlencoded", striped: true, // 设置为true会有隔行变色效果 search: true, showHeader: true, showColumns: true, showRefresh: true, pagination: true,//分页 sidePagination: 'server',//服务器端分页 pageNumber: 1, pageList: [5, 10, 20, 50],//分页步进值 detailView: true, smartDisplay: true, // 智能显示 pagination 和 cardview 等 onExpandRow: function () {$('body').setLang ('.detail-view');}, onPostBody: function (data) { if ($(this)[0].locale != undefined ) $('body').setLang ('#table'); }, detailFormatter: function (index, row, element) { return ': ' + row.MaxConn + ' ' + ': ' + row.NowConn + ' ' + ': ' + row.Flow.FlowLimit + 'm ' + ': ' + row.RateLimit + 'kb/s ' + ': ' + row.MaxTunnelNum + ' 

' + ': ' + row.WebUserName + ' ' + ': ' + row.WebPassword + ' ' + ': ' + row.Cnf.U + ' ' + ': ' + row.Cnf.P + ' 

' + ':  ' + ':  ' + ':

' + ': ' + "./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"" }, //表格的列 columns: [ { field: 'Id',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Remark',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Version',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'VerifyKey',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (!row.NoStore) { return value } else { return '' } } }, { field: 'Addr',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'InletFlow',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 sortable: true,//启用排序 formatter: function (value, row, index) { return changeunit(row.Flow.InletFlow) } }, { field: 'ExportFlow',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 sortable: true,//启用排序 formatter: function (value, row, index) { return changeunit(row.Flow.ExportFlow) } }, { field: 'IsConnect',//域值 title: '',//内容 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { return changeunit(row.Rate.NowRate) + "/S" } }, { field: 'Status',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (value) { return '' } else { return '' } } }, { field: 'IsConnect',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (value) { return '' } else { return '' } } }, { field: 'option',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { btn_group = '
' {{if eq true .isAdmin}} if (row.Status) { btn_group += '' } else { btn_group += '' } btn_group += '' {{end}} btn_group += ': ' + changeunit(row.Flow.ExportFlow) + ' ' + ': ' + changeunit(row.Flow.InletFlow) + ' ' + ': ' + row.Client.Cnf.Crypt + ' ' + ': ' + row.Client.Cnf.Compress + ' ' + ': ' + row.Client.Cnf.U + ' ' + ': ' + row.Client.Cnf.P + ' 

' + ': ' + row.CertFilePath + ' ' + ': ' + row.KeyFilePath + ' 

' + ': ' + row.HeaderChange + ' 

' + ': ' + row.HostChange + ' ' }, //表格的列 columns: [ { field: 'Id',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Id',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { return row.Client.Id } }, { field: 'Remark',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Host',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Scheme',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { return '' } }, { field: 'Target',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { return row.Target.TargetStr } }, { field: 'Location',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: '',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { hosturl = ((row.Scheme == 'http' ) ? 'http://' : 'https://') + row.Host + row.Location if (row.Client.IsConnect) { return '
' } else { return '' } } }, { field: 'option',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { btn_group = '
' btn_group += " /etc/npc/npc.conf << 'EOF' [common] server_addr=1.1.1.1:8024 vkey=abc123 [webapp] host=app.example.com target_addr=127.0.0.1:8080 host_change=localhost header_X-Real-IP=request_header_X-Forwarded-For [api] host=api.example.com target_addr=127.0.0.1:3000,127.0.0.1:3001 location=/v1 [static] host=app.example.com target_addr=127.0.0.1:8081 location=/static EOF ./npc -config=/etc/npc/npc.conf ``` -------------------------------- ### NPS Secret Proxy Configuration Example Source: https://github.com/ehang-io/nps/blob/master/docs/use.md Configuration for a secret proxy mode, likely for secure remote access like SSH. Requires a unique password for authentication and specifies the internal target address. ```ini [common] server_addr=1.1.1.1:8024 vkey=123 [secret_ssh] mode=secret password=ssh2 target_addr=10.1.50.2:22 ``` -------------------------------- ### Configure SOCKS5 Proxy via Client Config File Source: https://context7.com/ehang-io/nps/llms.txt Set up a SOCKS5 proxy using a client configuration file. This allows access to internal network resources as if on the internal network. ```bash # Client config for SOCKS5 proxy on port 1080 cat > /etc/npc/npc.conf << 'EOF' [common] server_addr=1.1.1.1:8024 vkey=abc123 [socks5] mode=socks5 server_port=1080 EOF ./npc -config=/etc/npc/npc.conf ``` -------------------------------- ### Integrate NPC SDK in C/C++ Source: https://context7.com/ehang-io/nps/llms.txt Embed NPC client functionality by linking against the shared library. Note that StartClientByVerifyKey blocks execution until the client exits. ```c // C/C++ SDK usage // Link with the npc shared library #include // Function declarations from npc SDK extern int StartClientByVerifyKey(char* server, char* vkey, char* conn_type, char* proxy); extern int GetClientStatus(); extern void CloseClient(); extern char* Version(); extern char* Logs(); int main() { // Get SDK version printf("NPC Version: %s\n", Version()); // Start client (blocks until client exits since v0.26.10) // Parameters: server_addr, vkey, conn_type (tcp/kcp), proxy (optional) int result = StartClientByVerifyKey( "1.1.1.1:8024", // Server address "your_vkey", // Verification key "tcp", // Connection type: tcp or kcp "" // Proxy: socks5://user:pass@host:port or empty ); // Check client status (1=online, 0=offline) int status = GetClientStatus(); printf("Client status: %d\n", status); // Get logs char* logs = Logs(); printf("Logs: %s\n", logs); // Close client CloseClient(); return 0; } // Compile: gcc -o myapp myapp.c -L. -lnpc ``` -------------------------------- ### Deploy NPS Client with Docker Source: https://context7.com/ehang-io/nps/llms.txt Run the NPC client as a Docker container, using host networking and providing server address and vkey as arguments. This is a simple way to connect the client without a configuration file. ```bash # Run NPC client docker run -d --name npc --net=host \ ffdfgdfg/npc \ -server=1.1.1.1:8024 -vkey=your_client_vkey ``` -------------------------------- ### Configure npc log level and path Source: https://github.com/ehang-io/nps/blob/master/docs/feature.md Set the log level and output file path for the npc client. ```shell -log_level=0~7 -log_path=npc.log ``` -------------------------------- ### Client Utility Commands Source: https://context7.com/ehang-io/nps/llms.txt Use NPC command-line utilities for diagnostics and management. ```APIDOC ## Client Utility Commands ### Description This section covers various command-line utilities provided by NPC for diagnostics, management, and operational tasks. ### NAT Type Check Check the Network Address Translation (NAT) type for P2P compatibility. ```bash ./npc nat -stun_addr=stun.stunprotocol.org:3478 # Output: NAT Type: Full Cone NAT / Restricted Cone NAT / Port Restricted NAT / Symmetric NAT ``` ### Status Check Check the client status, optionally with a specified configuration file. ```bash ./npc status -config=/etc/npc/npc.conf ``` ### Configuration Reload Reload the NPC configuration without restarting the client. ```bash ./npc restart -config=/etc/npc/npc.conf ``` ### IP Registration Register the current IP address for access when `ip_limit` is enabled on the server. ```bash ./npc register -server=1.1.1.1:8024 -vkey=your_vkey -time=2 # Registers current IP for 2 hours ``` ### Binary Update Update the NPC client binary. ```bash sudo npc stop sudo npc-update update sudo npc start ``` ### Logging Options Configure logging level and path for detailed diagnostics. ```bash ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -log_level=7 \ -log_path=/var/log/npc.log # Log levels: 0=Emergency, 1=Alert, 2=Critical, 3=Error, # 4=Warning, 5=Notice, 6=Info, 7=Debug ``` ### Connect Through Proxy Connect to the NPC server through a proxy (SOCKS5 or HTTP). ```bash # SOCKS5 proxy ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -proxy=socks5://user:pass@proxy.local:1080 # HTTP proxy ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -proxy=http://user:pass@proxy.local:8080 ``` ``` -------------------------------- ### Deploy NPS Server with Docker Source: https://context7.com/ehang-io/nps/llms.txt Run the NPS server as a Docker container, mapping the configuration directory and using host networking. Ensure the configuration directory is mounted correctly. ```bash # Run NPS server docker run -d --name nps --net=host \ -v /etc/nps/conf:/conf \ ffdfgdfg/nps ``` -------------------------------- ### Network Bandwidth Chart Data Configuration Source: https://github.com/ehang-io/nps/blob/master/web/views/index/index.html Sets up a line chart for network bandwidth (in/out). It requires a `changeunit` function for axis labels and a custom tooltip formatter. ```javascript chartdatas['bandwidth'] = { tooltip: { trigger: 'axis', formatter: function (params) { var str = params[0].axisValue + '
'; for (i in params){ str += '' + params[i].seriesName +': '+ changeunit(params[i].data) +'/s
'; } return str; } }, grid: { left: '3%', right: '3%', top: '5%', bottom: '3%', containLabel: true }, xAxis: { type: 'category', boundaryGap: false, data: ['{{.data.sys1.time}}', '{{.data.sys2.time}}', '{{.data.sys3.time}}', '{{.data.sys4.time}}', '{{.data.sys5.time}}', '{{.data.sys6.time}}', '{{.data.sys7.time}}', '{{.data.sys8.time}}', '{{.data.sys9.time}}', '{{.data.sys10.time}}'] }, yAxis: { type: 'value', axisLabel: { show: true, interval: 'auto', formatter: function (params){ return changeunit (params); } } }, series: [ { name: '', type: 'line', stack: 'in', smooth: true, data: ['{{.data.sys1.io_recv}}', '{{.data.sys2.io_recv}}', '{{.data.sys3.io_recv}}', '{{.data.sys4.io_recv}}', '{{.data.sys5.io_recv}}', '{{.data.sys6.io_recv}}', '{{.data.sys7.io_recv}}', '{{.data.sys8.io_recv}}', '{{.data.sys9.io_recv}}', '{{.data.sys10.io_recv}}'] }, { name: '', type: 'line', stack: 'out', smooth: true, data: ['{{.data.sys1.io_send}}', '{{.data.sys2.io_send}}', '{{.data.sys3.io_send}}', '{{.data.sys4.io_send}}', '{{.data.sys5.io_send}}', '{{.data.sys6.io_send}}', '{{.data.sys7.io_send}}', '{{.data.sys8.io_send}}', '{{.data.sys9.io_send}}', '{{.data.sys10.io_send}}'] } ] }; ``` -------------------------------- ### Configure and Establish P2P Tunnel Source: https://context7.com/ehang-io/nps/llms.txt Requires configuring p2p_ip and p2p_port in nps.conf and opening UDP ports. Symmetric NAT on both sides will prevent successful connections. ```bash # Prerequisites: Configure P2P in nps.conf # p2p_ip=1.1.1.1 # p2p_port=6000 # Open UDP ports 6000-6002 on firewall # Server-side client config (on internal network) cat > /etc/npc/npc.conf << 'EOF' [common] server_addr=1.1.1.1:8024 vkey=internal_client_vkey [p2p_ssh] mode=p2p password=my_p2p_secret target_addr=192.168.1.100:22 EOF ./npc -config=/etc/npc/npc.conf # Access-side client (on your local machine) ./npc -server=1.1.1.1:8024 -vkey=access_client_vkey \ -password=my_p2p_secret -target=192.168.1.100:22 \ -local_port=2222 # Connect via P2P tunnel ssh -p 2222 user@127.0.0.1 # Check NAT type compatibility ./npc nat -stun_addr=stun.stunprotocol.org:3478 # Symmetric NAT on both sides will fail # Other combinations have high success rate ``` -------------------------------- ### Render Environment Variables in NPS Client (No Config File) Source: https://github.com/ehang-io/nps/blob/master/docs/feature.md In non-configuration file mode, set environment variables like `NPC_SERVER_ADDR` and `NPC_SERVER_VKEY` before running the `npc` command. This allows dynamic configuration. ```bash export NPC_SERVER_ADDR=1.1.1.1:8024 export NPC_SERVER_VKEY=xxxxx ./npc ``` -------------------------------- ### Configure TCP Tunnel via Client Config File Source: https://context7.com/ehang-io/nps/llms.txt Use a client configuration file to set up a TCP tunnel for services like SSH or databases. Ensure the common server address and vkey are correctly set. ```bash cat > /etc/npc/npc.conf << 'EOF' [common] server_addr=1.1.1.1:8024 vkey=abc123 [ssh] mode=tcp target_addr=192.168.1.100:22 server_port=9022 EOF ./npc -config=/etc/npc/npc.conf ``` -------------------------------- ### Execute NPC Client Utility Commands Source: https://context7.com/ehang-io/nps/llms.txt Perform diagnostic tasks, manage client status, and update binaries using the NPC CLI. ```bash # Check NAT type (for P2P compatibility) ./npc nat -stun_addr=stun.stunprotocol.org:3478 # Output: NAT Type: Full Cone NAT / Restricted Cone NAT / Port Restricted NAT / Symmetric NAT # Check client status (config file mode) ./npc status -config=/etc/npc/npc.conf # Reload configuration without restart ./npc restart -config=/etc/npc/npc.conf # Register IP for access (when ip_limit enabled) ./npc register -server=1.1.1.1:8024 -vkey=your_vkey -time=2 # Registers current IP for 2 hours # Update client binary sudo npc stop sudo npc-update update sudo npc start # Logging options ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -log_level=7 \ -log_path=/var/log/npc.log # Log levels: 0=Emergency, 1=Alert, 2=Critical, 3=Error, # 4=Warning, 5=Notice, 6=Info, 7=Debug # Connect through proxy ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -proxy=socks5://user:pass@proxy.local:1080 # Or HTTP proxy ./npc -server=1.1.1.1:8024 -vkey=abc123 \ -proxy=http://user:pass@proxy.local:8080 ``` -------------------------------- ### Initialize ECharts System Charts Source: https://github.com/ehang-io/nps/blob/master/web/views/index/index.html Configures ECharts instances for system load, CPU usage, and memory consumption using template-injected data. ```javascript chartdatas['load'] = { tooltip: { trigger: 'axis', formatter: function (params) { var str = params[0].axisValue + '
'; for (i in params){ str += '' + params[i].seriesName +': '+ params[i].data +'
'; } return str; } }, grid: { left: '3%', right: '3%', top: '5%', bottom: '3%', containLabel: true }, xAxis: { type: 'category', boundaryGap: false, data: ['{{.data.sys1.time}}', '{{.data.sys2.time}}', '{{.data.sys3.time}}', '{{.data.sys4.time}}', '{{.data.sys5.time}}', '{{.data.sys6.time}}', '{{.data.sys7.time}}', '{{.data.sys8.time}}', '{{.data.sys9.time}}', '{{.data.sys10.time}}'] }, yAxis: { type: 'value' }, series: [ { name: '', type: 'line', stack: 'load1', smooth: true, data: [{{.data.sys1.load1}}, {{.data.sys2.load1}}, {{.data.sys3.load1}}, {{.data.sys4.load1}}, {{.data.sys5.load1}}, {{.data.sys6.load1}}, {{.data.sys7.load1}}, {{.data.sys8.load1}}, {{.data.sys9.load1}}, {{.data.sys10.load1}}] }, { name: '', type: 'line', stack: 'load5', smooth: true, data: [{{.data.sys1.load5}}, {{.data.sys2.load5}}, {{.data.sys3.load5}}, {{.data.sys4.load5}}, {{.data.sys5.load5}}, {{.data.sys6.load5}}, {{.data.sys7.load5}}, {{.data.sys8.load5}}, {{.data.sys9.load5}}, {{.data.sys10.load5}}] }, { name: '', type: 'line', stack: 'load15', smooth: true, data: [{{.data.sys1.load15}}, {{.data.sys2.load15}}, {{.data.sys3.load15}}, {{.data.sys4.load15}}, {{.data.sys5.load15}}, {{.data.sys6.load15}}, {{.data.sys7.load15}}, {{.data.sys8.load15}}, {{.data.sys9.load15}}, {{.data.sys10.load15}}] } ] }; chartdatas['cpu'] = { tooltip: { trigger: 'axis', formatter: function (params) { var str = params[0].axisValue + '
'; for (i in params){ str += '' + params[i].seriesName +': '+ params[i].data +'%
'; } return str; } }, grid: { left: '3%', right: '3%', top: '5%', bottom: '3%', containLabel: true }, xAxis: { type: 'category', boundaryGap: false, data: ['{{.data.sys1.time}}', '{{.data.sys2.time}}', '{{.data.sys3.time}}', '{{.data.sys4.time}}', '{{.data.sys5.time}}', '{{.data.sys6.time}}', '{{.data.sys7.time}}', '{{.data.sys8.time}}', '{{.data.sys9.time}}', '{{.data.sys10.time}}'] }, yAxis: { type: 'value', axisLabel: { show: true, interval: 'auto', formatter: '{value} %' } }, series: [ { name: '', type: 'line', stack: 'cpu', smooth: true, data: [{{.data.sys1.cpu}}, {{.data.sys2.cpu}}, {{.data.sys3.cpu}}, {{.data.sys4.cpu}}, {{.data.sys5.cpu}}, {{.data.sys6.cpu}}, {{.data.sys7.cpu}}, {{.data.sys8.cpu}}, {{.data.sys9.cpu}}, {{.data.sys10.cpu}}] } ] }; chartdatas['memory'] = { tooltip: { trigger: 'axis', formatter: function (params) { var str = params[0].axisValue + '
'; for (i in params){ str += '' + params[i].seriesName +': '+ params[i].data +'MB
'; } return str; } }, grid: { left: '3%', right: '3%', top: '5%', bottom: '3%', containLabel: true }, xAxis: { type: 'category', boundaryGap: false, data: ['{{.data.sys1.time}}', '{{.data.sys2.time}}', '{{.data.sys3.time}}', '{{.data.sys4.time}}', '{{.data.sys5.time}}', '{{.data.sys6.time}}', '{{.data.sys7.time}}', '{{.data.sys8.time}}', '{{.data.sys9.time}}', '{{.data.sys10.time}}'] }, yAxis: { type: 'value', axisLabel: { show: true, interval: 'auto', formatter: '{value} MB' } }, series: [ { name: '', type: 'line', stack: 'virtual_mem', smooth: true, data: [{{.data.sys1.virtual_mem}}, {{.data.sys2.virtual_mem}}, {{.data.sys3.virtual_mem}}, {{.data.sys4.virtual_mem}}, {{.data.sys5.virtual_mem}}, {{.data.sys6.virtual_mem}}, {{.data.sys7.virtual_mem}}, {{.data.sys8 ```