PHP code example of xiaosongshu / port-mapping

1. Go to this page and download the library: Download xiaosongshu/port-mapping library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xiaosongshu / port-mapping example snippets

 
composer create-project xiaosongshu/port-mapping
 


return [
    /** 代理ip 本服务器ip地址 */
    "server_ip" => "127.0.0.1",
    /** 代理端口 本服务器暴露的端口 nat_list为空生效 */
    "server_port" => 8001,
    /** 映射ip 被代理的服务器的ip地址  nat_list为空生效 */
    "local_ip" => "127.0.0.1",
    /** 映射端口 被代理的服务器的端口 nat_list为空生效*/
    "local_port" => 9501,
    /** channel 通道端口 */
    "channel_port" => 2206,
    /** 端口映射表 */
    "nat_list" => [
        [
            /** 访问端口 */
            "server_port" => 8000,
            /** 映射端口 */
            "local_port" => 9501,
            /** 映射IP */
            "local_ip" => "127.0.0.1",
        ],
        [
            /** 访问端口 */
            "server_port" => 8400,
            /** 映射端口 */
            "local_port" => 80,
            /** 映射IP */
            "local_ip" => "156.236.71.182",
        ],
    ]
];
bash 
php server.php start (-d)
bash 
php client.php start (-d)