Skip to content

Instantly share code, notes, and snippets.

View massoudasadi's full-sized avatar
🏠
Working from home

Massoud Asadi massoudasadi

🏠
Working from home
View GitHub Profile
@WangYihang
WangYihang / port-forwarding.py
Last active April 3, 2024 06:13
port forwarding via python socket
#!/usr/bin/env python3
# Tcp Port Forwarding (Reverse Proxy)
# Author : WangYihang <wangyihanger@gmail.com>
'''
+-----------------------------+ +---------------------------------------------+ +--------------------------------+
| My Laptop (Alice) | | Intermediary Server (Bob) | | Internal Server (Carol) |
+-----------------------------+ +----------------------+----------------------+ +--------------------------------+
| $ ssh -p 1022 carol@1.2.3.4 |<------->| IF 1: 1.2.3.4 | IF 2: 192.168.1.1 |<------->| IF 1: 192.168.1.2 |
| carol@1.2.3.4's password: | +----------------------+----------------------+ +--------------------------------+
@montanaflynn
montanaflynn / context.go
Last active September 13, 2023 12:51
An example of using context to cancel goroutines between server handlers
package main
import (
"context"
"fmt"
"log"
"net/http"
"sync"
"time"
)
/*****************************************************
* This code was compiled and tested on Ubuntu 18.04.1
* with kernel version 4.15.0
*****************************************************/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
@ncarandini
ncarandini / EditItem.razor
Last active February 17, 2022 07:21
[Blazor] Using IValidatableObject for form validation
<EditForm Model="@Item" OnValidSubmit="@(e => OnSave.InvokeAsync(Item))">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group">
<label for="Title">Name:</label>
<InputText id="Title" @bind-Value="Item.name" class="form-control" />
</div>
<div class="form-group">