Skip to content

Instantly share code, notes, and snippets.

View roblabla's full-sized avatar
🌅
Kernel Dev'ing.

Robin Lambertz roblabla

🌅
Kernel Dev'ing.
View GitHub Profile
function createServer({ host = '0.0.0.0',
port = 25565,
'online-mode' : onlineMode = true,
kickTimeout = 10 * 1000,
checkTimeoutInterval = 4 * 1000,
beforePing = null,
keepAlive = true,
motd = "A Minecraft server",
'max-players' : maxPlayers = 20,
} = {}) {
function readUInt4 (buffer, cursor) {
if (cursor % 2 === 0)
return buffer.readUInt8(Math.floor(cursor / 2)) >> 4;
else
return buffer.readUInt8(Math.floor(cursor / 2)) & 0x0f;
}
function writeUInt4(buffer, value, cursor) {
if (!(0 <= value && value < 16))
throw new Error('value is out of bounds');
var proto=require("./../../enums/protocol");
var fs=require("fs");
function getFieldInfo(field) {
if (Array.isArray(field))
return { type: field[0], typeArgs: field[1] };
else if (field.type && field.typeArgs)
return field;
else if (typeof field === "string")
return { type: field }
function findArgs(acc, v, k) {
if (typeof v === "string" && v[0] === '$')
acc.push({ "path": k, "val": v.subst(1) });
else if (Array.isArray(v) || typeof v === "object")
acc = acc.concat(_.map(_.reduce(v, findArgs, []), (v) => { "path": k + "." + v.path, "val": v.val }));
return acc;
}
function setField(path, val, into) {
var c = path.split('.').reverse();
[
[
"changed",
{
"state": "Play",
"bound": "toClient"
},
"0x0E",
"0x00"
],
{"typeId":"CPU","uid":1,"title":"1","head":{"functionName":"(root)","url":"","lineNumber":0,"callUID":2584701498,"bailoutReason":"","id":1,"scriptId":0,"hitCount":0,"children":[{"functionName":"listOnTimeout","url":"timers.js","lineNumber":75,"callUID":3200520433,"bailoutReason":"TryFinallyStatement","id":2,"scriptId":45,"hitCount":0,"children":[{"functionName":"Module.runMain","url":"module.js","lineNumber":499,"callUID":3304910521,"bailoutReason":"no reason","id":3,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module._load","url":"module.js","lineNumber":273,"callUID":1489921527,"bailoutReason":"TryFinallyStatement","id":4,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module.load","url":"module.js","lineNumber":345,"callUID":1425125897,"bailoutReason":"no reason","id":5,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module._extensions..js","url":"module.js","lineNumber":476,"callUID":985763658,"bailoutReason":"no reason","id":6,"scriptId":34,"hitCount":0,"children":[{"functionNa
{"typeId":"CPU","uid":1,"title":"1","head":{"functionName":"(root)","url":"","lineNumber":0,"callUID":2584701498,"bailoutReason":"","id":1,"scriptId":0,"hitCount":0,"children":[{"functionName":"listOnTimeout","url":"timers.js","lineNumber":75,"callUID":3786248223,"bailoutReason":"TryFinallyStatement","id":2,"scriptId":45,"hitCount":0,"children":[{"functionName":"Module.runMain","url":"module.js","lineNumber":499,"callUID":1673154358,"bailoutReason":"no reason","id":3,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module._load","url":"module.js","lineNumber":273,"callUID":1852573627,"bailoutReason":"TryFinallyStatement","id":4,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module.load","url":"module.js","lineNumber":345,"callUID":142552180,"bailoutReason":"no reason","id":5,"scriptId":34,"hitCount":0,"children":[{"functionName":"Module._extensions..js","url":"module.js","lineNumber":476,"callUID":3486571580,"bailoutReason":"no reason","id":6,"scriptId":34,"hitCount":0,"children":[{"functionNa
@roblabla
roblabla / proxy_raw.js
Created October 18, 2015 11:17
A raw proxy for NMP
var mc = require('minecraft-protocol') // import nmp
, states = mc.states // import states as var from nmp
, server = new mc.Server();
server.listen(25565);
server.on('connection', function(client) {
var addr = client.socket.remoteAddress; // get the ip
console.log('Incoming connection', '(' + addr + ')'); // print ip on connection
var endedClient = false;
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
let
hydra = (import <nixpkgs> {}).fetchgit {
url = https://github.com/NixOS/hydra;
rev = "30823078c4b043675f22c77d20833f3b78f7bb9f";
{
# Used by the container to access the outside world.
networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"];
networking.nat.externalInterface = "enp1s0";
containers.vpn = {
privateNetwork = true;
hostAddress = "192.168.100.10";
localAddress = "192.168.100.11";