Skip to content

Commit

Permalink
fix indent
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Aug 21, 2024
1 parent 2557045 commit 46366e2
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/browser/fake_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,45 +900,45 @@ function make_packet(spec) {

function fake_tcp_connect(dport, adapter)
{
// TODO: check port collisions
let sport = 49152 + Math.floor(Math.random() * 1000);
let tuple = [
adapter.vm_ip.join("."),
dport,
adapter.router_ip.join("."),
sport
].join(":");

let reader;
let connector;

let conn = new TCPConnection();
conn.net = adapter;
conn.on_data = function(data) { if(reader) reader.call(handle, data); };
conn.on_connect = function() { if(connector) connector.call(handle); };
conn.tuple = tuple;

conn.hsrc = adapter.router_mac;
conn.psrc = adapter.router_ip;
conn.sport = sport;
conn.hdest = adapter.vm_mac;
conn.dport = dport;
conn.pdest = adapter.vm_ip;

adapter.tcp_conn[tuple] = conn;
conn.connect();

// TODO: Real event source
let handle = {
write: function(data) { conn.write(data); },
on: function(event, cb) {
if( event === "data" ) reader = cb;
if( event === "connect" ) connector = cb;
},
close: function() { conn.close(); }
};
// TODO: check port collisions
let sport = 49152 + Math.floor(Math.random() * 1000);
let tuple = [
adapter.vm_ip.join("."),
dport,
adapter.router_ip.join("."),
sport
].join(":");

let reader;
let connector;

let conn = new TCPConnection();
conn.net = adapter;
conn.on_data = function(data) { if(reader) reader.call(handle, data); };
conn.on_connect = function() { if(connector) connector.call(handle); };
conn.tuple = tuple;

conn.hsrc = adapter.router_mac;
conn.psrc = adapter.router_ip;
conn.sport = sport;
conn.hdest = adapter.vm_mac;
conn.dport = dport;
conn.pdest = adapter.vm_ip;

adapter.tcp_conn[tuple] = conn;
conn.connect();

// TODO: Real event source
let handle = {
write: function(data) { conn.write(data); },
on: function(event, cb) {
if( event === "data" ) reader = cb;
if( event === "connect" ) connector = cb;
},
close: function() { conn.close(); }
};

return handle;
return handle;
}

/**
Expand Down

0 comments on commit 46366e2

Please sign in to comment.