Skip to content

Instantly share code, notes, and snippets.

View scorredoira's full-sized avatar

Santiago Corredoira Lascaray scorredoira

View GitHub Profile
import "stdlib/native"
export function main() {
let url = http.parseURL("http://example.com/")
let proxy = httputil.newSingleHostReverseProxy(url)
let server = http.newServer()
server.address = ":9999"
server.handler = (w, r) => {
r.url.host = url.host
@scorredoira
scorredoira / tcproxy.ts
Created May 23, 2020 17:56
A simple TCP proxy
/**
* ------------------------------------------------------------------
* A simple TCP proxy.
*
* Configuration example:
*
* {
* "rules": [
* { "local": ":99995", "remote": "127.0.0.18:22" },
* { "local": ":99996", "remote": "127.0.0.19:22" },
# flush iptable rules
iptables -F
# Allowing DNS lookups (tcp, udp port 53)
iptables -A OUTPUT -p tcp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
# Allow web traffic
@scorredoira
scorredoira / reset.sh
Created May 8, 2020 14:58
Reset iptables
iptables -F
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
@scorredoira
scorredoira / iptables.sh
Last active December 6, 2020 13:42
iptables rules
# flush iptable rules
iptables -F
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Allowing DNS lookups (tcp, udp port 53)
iptables -A OUTPUT -p tcp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
@scorredoira
scorredoira / plantillas.aspx
Created November 15, 2019 15:57
Snippets Plantillas
<% if(client) { %>
<h2><%= client.name %></h2>
<% } %>
import "stdlib/native";
function main() {
let s = http.newServer();
s.address = ":8081";
s.handler = zipHandler
s.start();
}
function zipHandler(w: http.Response, r: http.Request) {
class YieldTable {
element: HTMLElement;
constructor(data: Data) {
this.element = S.create("div", "amura_yield_table")
this.parseValues(data)
this.render(data)
}
private parseValues(data: Data) {
import "stdlib/native"
import * as web from "stdlib/web";
export function getPluginInfo() {
return {
name: "@@Buscador",
description: "@@Añade un buscador global en la barra superior."
}
}
let data = { "email_address": time.unixNano() + "@prueba.com", "status": "subscribed" };
let r = http.newRequest("POST", "https://us19.api.mailchimp.com/3.0/lists/1652876acb/members", data)
r.setBasicAuth("xx", "xx")
r.execute()
r = http.newRequest("GET", "https://us19.api.mailchimp.com/3.0/lists/1652876acb/members", data)
r.setBasicAuth("xxx", "xx")
let res = json.unmarshal(r.execute())
fmt.println(res.total_items)