{"action":"created","issue":{"url":"https://api.github.com/repos/xtaci/kcptun/issues/79","repository_url":"https://api.github.com/repos/xtaci/kcptun","labels_url":"https://api.github.com/repos/xtaci/kcptun/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/xtaci/kcptun/issues/79/comments","events_url":"https://api.github.com/repos/xtaci/kcptun/issues/79/events","html_url":"https://github.com/xtaci/kcptun/issues/79","id":168461400,"number":79,"title":"go-mips32 交叉编译go程序 编译kcptun例子","user":{"login":"hiboyhiboy","id":10822946,"avatar_url":"https://avatars.githubusercontent.com/u/10822946?v=3","gravatar_id":"","url":"https://api.github.com/users/hiboyhiboy","html_url":"https://github.com/hiboyhiboy","followers_url":"https://api.github.com/users/hiboyhiboy/followers","following_url":"https://api.github.com/users/hiboyhiboy/following{/other_user}","gists_url":"https://api.github.com/users/hiboyhiboy/gists{/gist_id}","starred_url":"https://api.github.com/users/hiboyhiboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiboyhiboy/subscriptions","organizations_url":"https://api.github.com/users/hiboyhiboy/orgs","repos_url":"https://api.github.com/users/hiboyhiboy/repos","events_url":"https://api.github.com/users/hiboyhiboy/events{/privacy}","received_events_url":"https://api.github.com/users/hiboyhiboy/received_events","type":"User","site_admin":false},"labels":[{"id":332340739,"url":"https://api.github.com/repos/xtaci/kcptun/labels/enhancement","name":"enhancement","color":"5319e7","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-07-30T10:41:04Z","updated_at":"2016-12-07T17:06:57Z","closed_at":"2016-08-09T14:14:37Z","body":"**# 一、交叉编译环境配置**\n\n来源网友博文： [极路由1s(mt7620a)OpenWrt交叉编译go程序](http://studygolang.com/articles/7326)\n\n// 下载go-mips32源 \ngit clone https://github.com/gomini/go-mips32.git \ncd go-mips32/src\n\n// 配置GO编译参数 \nexport GOOS=linux \nexport GOARCH=mips32le\n\n// 执行编译\n\n./make.bash \ncd ..\n\n// 创建编译后文件存放文件夹 \nsudo mkdir /opt/mipsgo\n\n// 复制 \nsudo cp -R \\* /opt/mipsgo\n\n// 如果第一步无报错完成后再继续下一步操作，如果出现问题请Google修复，或更换系统，我用ubuntukylin-15.10编译成功。\n\n**# 二、编译kcptun**\n\n源码来源：https://github.com/xtaci/kcptun\n\n// 创建程序目录\nmkdir /opt/kcptun\ncd /opt/kcptun\n\n// go工程参数配置 \nexport GOPATH=/opt/mipsgo/src/gocode\nexport GOOS=linux \nexport GOARCH=mips32le\nexport GOROOT=/opt/mipsgo \nexport PATH=/opt/mipsgo/bin:$PATH\n\n// 提前下载kcptun的依赖库\ngo get -v  golang.org/x/crypto/pbkdf2\ngo get -v  github.com/xtaci/kcp-go\ngo get -v  github.com/urfave/cli\ngo get -v  github.com/hashicorp/yamux\ngo get -v  github.com/golang/snappy\ngo get -v  golang.org/x/net/ipv4\n\n// 由于依赖库没mips32le，需要填坑\n// go get -v  golang.org/x/net/ipv4\n// 运行以上命令时会提示报错：/golang.org/x/net/ipv4/icmp.go:34:2: error: use of undefined type 'sysICMPFilter'\n// 参考补丁填坑：https://bugzilla.redhat.com/attachment.cgi?id=1147705&action=diff\n// 填坑步骤：gen.go里面添加mips32le的判断。复制一个zsys_linux_mips64le.go文件，改名zsys_linux_mips32le.go\n// zsys_linux_mips32.go和zsys_linux_mips32le.go文件里面的64字符也要修改。\n// +build linux,mips32\n// +build linux,mips32le\n\n// 填坑完成后再运行一次：\ngo get -v  golang.org/x/net/ipv4\n\n// 下载kcptun\ngo get -v  github.com/xtaci/kcptun/client\ngo get -v  github.com/xtaci/kcptun/server\n\n// 编译\nVERSION=`date -u +%Y%m%d`\nLDFLAGS=\"-X main.VERSION=$VERSION -s -w\"\nenv CGO_ENABLED=0 GOOS=linux GOARCH=mips32le go build -ldflags \"$LDFLAGS\" -o client_linux_mips  github.com/xtaci/kcptun/client\nenv CGO_ENABLED=0 GOOS=linux GOARCH=mips32le go build -ldflags \"$LDFLAGS\" -o server_linux_mips  github.com/xtaci/kcptun/server\n\n// 几秒后出现程序文件，编译成功。我们路由只需要用client。\n// 毕竟路由不做server，server主程序要去github下载或参考以上步骤，改export GOARCH=amd64就能自己编译amd64版本。\n\n**# 三、部署服务**\n\n// kcptun服务端部署教程\n// https://blog.kuoruan.com/102.html\n// http://www.cmsky.com/kcptun/\n\n// 服务器:\n./server_linux_amd64 -t \"服务器IP地址:8388\" -l \":554\" -key hiboy -mtu 1400 -sndwnd 2048 -rcvwnd 2048 --crypt none --mode fast2 --nocomp  // 转发到服务器的本地8388端口\n// crypt：xor/none都不算加密，通过参数 -nocomp 在两端同时设定以关闭压缩。key可以自定义\n\n// kcptun配置客户端参考\n\n// 客户端: \n./client_linux_mips -r \"服务器IP地址:554\" -l \":8388\" -key hiboy -mtu 1400 -sndwnd 256 -rcvwnd 2048 --crypt none --mode fast2 --nocomp  -dscp 46   // 监听客户端的本地8388端口\n// xor/none都不算加密，通过参数 -nocomp 在两端同时设定以关闭压缩。key可以自定义\n// D1双核4线程可以添加 [--conn 4] 参数实现多线程下载\n\n// Shadowsocks 客户端配置\n// 在SS服务器新建服务端口：8388\n// 路由SS配置服务器地址:：127.0.0.1\n// 路由SS配置服务器端口:：8388\n// 正确填写你的 Shadowsocks 密码，加密方式，协议和混淆方式。\n// 两边都启动kcptun、启动SS，测试是否正确运行。\n\n// 已经在华硕7620固件测试有效，稍后会集成到固件里面的。\n\nsndwnd/rcvwnd 设定参考\nsndwnd \\* mtu 不能超过上行带宽, rcvwnd \\* mtu 不能超过下行带宽\n对延迟不敏感的情况，比如只用于数据传输，可以用MODE_FAST，20ms的内部时钟，默认值\n对延迟敏感的情况，可以用FAST2模式，但必须严格注意第一条规则\n更多说明移步：https://github.com/xtaci/kcptun\n"},"comment":{"url":"https://api.github.com/repos/xtaci/kcptun/issues/comments/265507268","html_url":"https://github.com/xtaci/kcptun/issues/79#issuecomment-265507268","issue_url":"https://api.github.com/repos/xtaci/kcptun/issues/79","id":265507268,"user":{"login":"dfangboy","id":16333542,"avatar_url":"https://avatars.githubusercontent.com/u/16333542?v=3","gravatar_id":"","url":"https://api.github.com/users/dfangboy","html_url":"https://github.com/dfangboy","followers_url":"https://api.github.com/users/dfangboy/followers","following_url":"https://api.github.com/users/dfangboy/following{/other_user}","gists_url":"https://api.github.com/users/dfangboy/gists{/gist_id}","starred_url":"https://api.github.com/users/dfangboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfangboy/subscriptions","organizations_url":"https://api.github.com/users/dfangboy/orgs","repos_url":"https://api.github.com/users/dfangboy/repos","events_url":"https://api.github.com/users/dfangboy/events{/privacy}","received_events_url":"https://api.github.com/users/dfangboy/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T17:06:57Z","updated_at":"2016-12-07T17:06:57Z","body":"有编译好这个吗。可以直接抛弃ss了\r\nhttps://github.com/kcptunsocks/kcptun/tree/router\r\n我自己编译了客户端可以连接。但是一访问就奔溃了。\r\n服务端这里有编译好的https://github.com/clangcn/kcp-server\r\n下面的是不是就是压缩的问题导致的？\r\n2016/12/07 16:23:34 main.go:256: version: SELFBUILD\r\n2016/12/07 16:23:36 main.go:292: listening on: [::]:1090\r\n2016/12/07 16:23:36 main.go:293: encryption: salsa20\r\n2016/12/07 16:23:36 main.go:294: nodelay parameters: 0 20 2 1\r\n2016/12/07 16:23:36 main.go:295: remote address: XXX.XXX.XXX.XXX:XXX\r\n2016/12/07 16:23:36 main.go:296: sndwnd: 128 rcvwnd: 256\r\n2016/12/07 16:23:36 main.go:297: compression: true\r\n2016/12/07 16:23:36 main.go:298: mtu: 1350\r\n2016/12/07 16:23:36 main.go:299: datashard: 10 parityshard: 3\r\n2016/12/07 16:23:36 main.go:300: acknodelay: false\r\n2016/12/07 16:23:36 main.go:301: dscp: 0\r\n2016/12/07 16:23:36 main.go:302: sockbuf: 4194304\r\n2016/12/07 16:23:36 main.go:303: keepalive: 10\r\n2016/12/07 16:23:36 main.go:304: conn: 1\r\n2016/12/07 16:23:36 main.go:305: autoexpire: 0\r\n2016/12/07 16:23:36 main.go:306: redir: \r\n2016/12/07 16:23:52 trans.go:56: new socks5 conn by www.google.com.hk:80\r\npanic: runtime error: slice bounds out of range\r\n\r\ngoroutine 13 [running]:\r\ngithub.com/golang/snappy.encodeBlock(0x105c0013, 0x12ac9, 0x12ac9, 0x1058a000, 0x1d, 0x10000, 0x8fa14357)\r\n        /root/kcptun/src/github.com/golang/snappy/encode_other.go:175 +0x10c4\r\ngithub.com/golang/snappy.Encode(0x105c0012, 0x12aca, 0x12aca, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/golang/snappy/encode.go:37 +0x370\r\ngithub.com/golang/snappy.(*Writer).write(0x1053c6f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/golang/snappy/encode.go:229 +0x280\r\ngithub.com/golang/snappy.(*Writer).Flush(0x1053c6f0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/golang/snappy/encode.go:272 +0xb0\r\nmain.(*compStream).Write(0x10538880, 0x1061c000, 0x1d, 0x10008, 0x1d, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:39 +0x88\r\ngithub.com/xtaci/smux.(*Session).sendLoop(0x1050c1e0)\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:309 +0x5cc\r\ncreated by github.com/xtaci/smux.newSession\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:78 +0x3d8\r\n\r\ngoroutine 1 [runnable]:\r\nnet.(*pollDesc).Wait(0x10530138, 0x72, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:84 +0x4c\r\nnet.(*pollDesc).WaitRead(0x10530138, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:89 +0x48\r\nnet.(*netFD).accept(0x10530100, 0x0, 0x775fda88, 0x1053868c)\r\n        /root/go-mips32/src/net/fd_unix.go:419 +0x3dc\r\nnet.(*TCPListener).AcceptTCP(0x1051c690, 0x1051c2c0, 0x0, 0x0)\r\n        /root/go-mips32/src/net/tcpsock_posix.go:234 +0x58\r\nmain.func·004(0x10500820, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:361 +0x2638\r\ngithub.com/urfave/cli.HandleAction(0x234288, 0x2e0b28, 0x10500820, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/urfave/cli/app.go:485 +0x100\r\ngithub.com/urfave/cli.(*App).Run(0x10564000, 0x1050a000, 0x3, 0x3, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/urfave/cli/app.go:259 +0xba4\r\nmain.main()\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:392 +0x1418\r\n\r\ngoroutine 5 [syscall]:\r\nos/signal.loop()\r\n        /root/go-mips32/src/os/signal/signal_unix.go:21 +0x30\r\ncreated by os/signal.init·1\r\n        /root/go-mips32/src/os/signal/signal_unix.go:27 +0x58\r\n\r\ngoroutine 6 [chan receive]:\r\nmain.sigHandler()\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/signal.go:23 +0x150\r\ncreated by main.init·1\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/signal.go:15 +0x48\r\n\r\ngoroutine 7 [select]:\r\ngithub.com/xtaci/kcp-go.(*UDPSession).updateTask(0x10560080)\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:511 +0x33c\r\ncreated by github.com/xtaci/kcp-go.newUDPSession\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:120 +0x534\r\n\r\ngoroutine 8 [select]:\r\ngithub.com/xtaci/kcp-go.(*UDPSession).outputTask(0x10560080)\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:412 +0x1a60\r\ncreated by github.com/xtaci/kcp-go.newUDPSession\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:121 +0x564\r\n\r\ngoroutine 9 [select]:\r\ngithub.com/xtaci/kcp-go.(*UDPSession).readLoop(0x10560080)\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:630 +0x50c\r\ncreated by github.com/xtaci/kcp-go.newUDPSession\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:123 +0x5a4\r\n\r\ngoroutine 11 [IO wait]:\r\nnet.(*pollDesc).Wait(0x10530df8, 0x72, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:84 +0x4c\r\nnet.(*pollDesc).WaitRead(0x10530df8, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:89 +0x48\r\nnet.(*netFD).readFrom(0x10530dc0, 0x10563800, 0x800, 0x800, 0x0, 0x0, 0x0, 0x775fda88, 0x105385a8)\r\n        /root/go-mips32/src/net/fd_unix.go:269 +0x418\r\nnet.(*UDPConn).ReadFromUDP(0x1051c3d8, 0x10563800, 0x800, 0x800, 0x0, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/net/udpsock_posix.go:67 +0x108\r\nnet.(*UDPConn).ReadFrom(0x1051c3d8, 0x10563800, 0x800, 0x800, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/net/udpsock_posix.go:82 +0x104\r\ngithub.com/xtaci/kcp-go.(*UDPSession).receiver(0x10560080, 0x10530340)\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:611 +0x108\r\ncreated by github.com/xtaci/kcp-go.(*UDPSession).readLoop\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:627 +0x84\r\n\r\ngoroutine 12 [select]:\r\ngithub.com/xtaci/kcp-go.(*UDPSession).Read(0x10560080, 0x105ec000, 0x4, 0x12ace, 0x0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcp-go/sess.go:184 +0x8d0\r\nio.ReadAtLeast(0x775ff2c0, 0x10560080, 0x105ec000, 0x4, 0x12ace, 0x4, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/io/io.go:298 +0x118\r\nio.ReadFull(0x775ff2c0, 0x10560080, 0x105ec000, 0x4, 0x12ace, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/io/io.go:316 +0x6c\r\ngithub.com/golang/snappy.(*Reader).readFull(0x10530380, 0x105ec000, 0x4, 0x12ace, 0x1, 0x0)\r\n        /root/kcptun/src/github.com/golang/snappy/decode.go:108 +0x6c\r\ngithub.com/golang/snappy.(*Reader).Read(0x10530380, 0x10600000, 0x8, 0x10008, 0x10500e60, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/golang/snappy/decode.go:128 +0x1bc\r\nmain.(*compStream).Read(0x10538880, 0x10600000, 0x8, 0x10008, 0x2, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:34 +0x5c\r\nio.ReadAtLeast(0x775ff318, 0x10538880, 0x10600000, 0x8, 0x10008, 0x8, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/io/io.go:298 +0x118\r\nio.ReadFull(0x775ff318, 0x10538880, 0x10600000, 0x8, 0x10008, 0x775f0a14, 0x0, 0x0)\r\n        /root/go-mips32/src/io/io.go:316 +0x6c\r\ngithub.com/xtaci/smux.(*Session).readFrame(0x1050c1e0, 0x10600000, 0x10008, 0x10008, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:194 +0x104\r\ngithub.com/xtaci/smux.(*Session).recvLoop(0x1050c1e0)\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:229 +0x1d8\r\ncreated by github.com/xtaci/smux.newSession\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:77 +0x3ac\r\n\r\ngoroutine 14 [select]:\r\ngithub.com/xtaci/smux.(*Session).keepalive(0x1050c1e0)\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:277 +0x360\r\ncreated by github.com/xtaci/smux.newSession\r\n        /root/kcptun/src/github.com/xtaci/smux/session.go:79 +0x404\r\n\r\ngoroutine 15 [select]:\r\nmain.scavenger(0x10530480)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:409 +0x648\r\ncreated by main.func·004\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:358 +0x2620\r\n\r\ngoroutine 16 [select]:\r\ngithub.com/xtaci/smux.(*Stream).Write(0x1053a090, 0x10536143, 0x15, 0x12d, 0x0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/smux/stream.go:111 +0x6c0\r\nmain.handleSocks5Client(0x775ff390, 0x1051c2b8, 0x775ff3b0, 0x1053a090, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/trans.go:70 +0x7a0\r\ncreated by main.func·004\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:388 +0x3104\r\n\r\ngoroutine 17 [runnable]:\r\nnet.(*pollDesc).Wait(0x10530a38, 0x72, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:84 +0x4c\r\nnet.(*pollDesc).WaitRead(0x10530a38, 0x0, 0x0)\r\n        /root/go-mips32/src/net/fd_poll_runtime.go:89 +0x48\r\nnet.(*netFD).Read(0x10530a00, 0x10536280, 0x107, 0x130, 0x0, 0x775fda88, 0x10538878)\r\n        /root/go-mips32/src/net/fd_unix.go:242 +0x3e0\r\nnet.(*conn).Read(0x1051c2c0, 0x10536280, 0x107, 0x130, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/net/net.go:121 +0xf0\r\nio.ReadAtLeast(0x775ff3d0, 0x1051c2c0, 0x10536280, 0x107, 0x130, 0x5, 0x0, 0x0, 0x0)\r\n        /root/go-mips32/src/io/io.go:298 +0x118\r\nmain.getRequest(0x10536280, 0x130, 0x130, 0x775ff390, 0x1051c2c0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/trans.go:138 +0xe4\r\nmain.handleSocks5Client(0x775ff390, 0x1051c2c0, 0x775ff3b0, 0x1053a1b0, 0x0, 0x0)\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/trans.go:55 +0x2cc\r\ncreated by main.func·004\r\n        /root/kcptun/src/github.com/xtaci/kcptun/client/main.go:388 +0x3104"}}
{"actor":{"display_login":"dfangboy"}}