Skip to content

Commit

Permalink
update vpn build, add node-rohc
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwerfling committed Jul 25, 2024
1 parent f001d1b commit cf35d35
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions vpn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions vpn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions vpn/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ 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
*/
(async(): Promise<void> => {
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());
Expand Down

0 comments on commit cf35d35

Please sign in to comment.