欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jslinux-network 博客分类: jslinux jslinuxkerneltunCONFIG_TUN 

程序员文章站 2024-03-06 13:46:02
...
git clone https://github.com/killinux/jslinux-network

把 jslinux-network 放在apache或者nginx中。

yum install python-virtualenv

virtualenv mysite

source mysite/bin/activate

pip install mod_pywebsocket

cd jslinux-network/websocketstuntap

这里需要tap_wsh.py
python -m mod_pywebsocket.standalone -d . --log-level=info -p 3000

或launch.sh

这时,ifconfig

假设本机IP是192.168.139.85
vim network-websockets.js
第7行改成
tuntapWS_connection = new WebSocket('ws://192.168.139.85:3000/tap', []);


chrome:
http://192.168.137.85/jslinux-network

先点boot
启动后,点connect or reconnect websockets启动websocket
chrome变黄色

这时观察后台launch.sh会建立个链接一个连接
(mysite)[root@centos32 websocketstuntap]# ./launch.sh 
[2016-05-30 10:54:50,203] [INFO] __main__.WebSocketServer: Create socket on: (10, 1, '', '', '')
[2016-05-30 10:54:50,204] [INFO] __main__.WebSocketServer: Create socket on: (2, 1, '', '', '')
[2016-05-30 10:54:50,204] [INFO] __main__.WebSocketServer: Bind on: (10, 1, '', '', '')
[2016-05-30 10:54:50,205] [INFO] __main__.WebSocketServer: Bind on: (2, 1, '', '', '')
[2016-05-30 10:54:50,205] [INFO] __main__.WebSocketServer: Listen on: (10, 1, '', '', '')
[2016-05-30 10:54:50,205] [INFO] __main__.WebSocketServer: Listen on: (2, 1, '', '', '')
[2016-05-30 10:54:50,205] [INFO] __main__.WebSocketServer: Skip by failure: error(98, 'Address already in use')
[2016-05-30 10:56:23,729] [INFO] mod_pywebsocket.handshake: Established (RFC 6455 protocol)
tuntapdevice: websockettuntap



ifconfig观察服务器会多个tap设备
websockettuntap: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.1  netmask 255.0.0.0  broadcast 10.255.255.255
        inet6 fe80::d894:8ff:fec0:b547  prefixlen 64  scopeid 0x20<link>
        ether da:94:08:c0:b5:47  txqueuelen 500  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@centos32 linuxstart-20120111]# 


默认IP是10.0.2.1

进入jslinux后
cat /dev/clipboard|sh
生成tap设备

默认的ip是10.0.2.2
ping 10.0.2.1
能ping通表示正常


如果是自己编译的内核
需要注意.config文件一定要多一条
# CONFIG_EQUALIZER is not set
CONFIG_TUN=y

否则jslinux在建立tap设备的时候会说找不到设备的问题


chrome://appcache-internals/
可以看到浏览器的cache


如果想把120M的镜像放在这里
需要改
jslinux.js里面的
197     //params.hda = { url: "hda%d.bin", block_size: 64, nb_blocks: 912 };
198     params.hda = { url: "hda%d.bin", block_size: 64, nb_blocks: 2000 };

否则会报
attempt to access beyond end of device
的错误