diff --git a/vpn/Dockerfile b/vpn/Dockerfile index 363fd49..8a20acd 100644 --- a/vpn/Dockerfile +++ b/vpn/Dockerfile @@ -6,6 +6,23 @@ RUN apt-get update -y RUN apt-get upgrade -y RUN npm install -g node-gyp +# Install Rohc --------------------------------------------------------------------------------------------------------- + +RUN apt-get install autotools-dev -y +RUN apt-get install automake -y +RUN apt-get install libtool -y +RUN apt-get install libpcap-dev -y +RUN apt-get install libcmocka-dev -y + +WORKDIR /opt/ +RUN git clone https://github.com/stefanwerfling/rohc.git +WORKDIR /opt/rohc/ +RUN ./autogen.sh --prefix=/usr +RUN make all +RUN make install + +# Create dirs ---------------------------------------------------------------------------------------------------------- + RUN mkdir -p /opt/flyingfish RUN mkdir -p /opt/flyingfish/schemas RUN mkdir -p /opt/flyingfish/core @@ -57,6 +74,9 @@ RUN npm run build WORKDIR /opt/flyingfish/node_modules/tuntap2 RUN npm run build --loglevel verbose +WORKDIR /opt/flyingfish/node_modules/node-rohc +RUN npm run build --loglevel verbose + WORKDIR /opt/flyingfish/vpn RUN npm run build diff --git a/vpn/package.json b/vpn/package.json index 06ba3cd..3afc7c9 100644 --- a/vpn/package.json +++ b/vpn/package.json @@ -43,6 +43,7 @@ "got": "^12.5.3", "node-schedule": "^2.1.0", "tuntap2": "git+https://github.com/stefanwerfling/node-tuntap2.git#ESModule", + "node-rohc": "git+https://github.com/stefanwerfling/node-rohc.git", "uuid": "^9.0.0", "ws": "^8.12.1", "vts": "git+https://github.com/OpenSourcePKG/vts.git", diff --git a/vpn/src/main.ts b/vpn/src/main.ts index a868bb2..2418b87 100644 --- a/vpn/src/main.ts +++ b/vpn/src/main.ts @@ -2,6 +2,7 @@ import * as process from 'process'; import {Tun} from 'tuntap2'; import {IP} from './inc/Decode/IP.js'; import {IPv4} from './inc/Decode/IPv4.js'; +import {Rohc} from 'node-rohc'; /** * Main @@ -9,12 +10,15 @@ import {IPv4} from './inc/Decode/IPv4.js'; (async(): Promise => { try { const tun = new Tun(); + const rohc = new Rohc(); tun.mtu = 1400; tun.ipv4 = '4.3.2.1/24'; tun.on('data', (buf) => { + const cmpBuf = rohc.compress(new Uint8Array(buf)); const ippacket = IP.decodeIP(buf); console.log(ippacket); + console.log(cmpBuf); if (ippacket instanceof IPv4) { console.log(ippacket.getSourceAddress().toString());