Archive for November, 2018

A simple change to make your website #IPv6 ready.


Making your website accessible by both IPv4 (What everyone is familiar with) and IPv6, those wierd long IP addresses with hex numbers in them, is as simple as

(1) finding your IPv6 address, which you can do by doing a IPConfig /all on your desktop

And getting the IPv6 address from the “6TO4 adapter”

Tunnel adapter 6TO4 Adapter:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft 6to4 Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2002:5f9a:f46a::5f9a:f46a(Preferred)
Default Gateway . . . . . . . . . : 2002:c058:6301::1
DHCPv6 IAID . . . . . . . . . . . : 469762048
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-42-14-1B-00-25-90-1E-04-94

(2) Then adding a DNS entry for an AAAA record pointing to the IPv6 address that you found above.

I doubt it will make much difference today or tomorrow, since IPv4 will take a long long time to die out completely, but slowly, IPv6 will become the norm, and it’s best to be ahead of the curve, rather than being behind it.



Categories: Uncategorized

Run #ASP.NET on #Ubuntu using .NET Core

Screenshot 2018-11-27 at 10.54.01

Yes, it’s possible to host ASP.NET on linux, and there are plenty of great tutorials out there, and this is just a quick post with a few of my tips thrown in…

I followed the tutorial at, using a EC2 instance from Amazon.

However, at the point where it says, “point a browser at https://localhost:5001” I had to get a bit inventive,

So, I opened up port 5001 in security settings, and I created a release build

dotnet build –configuration Release

Navigated to the “publish” folder and ran this command to have the app listen on all hosts, not just localhost.

dotnet myWebAppp.dll –urls

Then from my mac, I could navigate to https://%5BIP%5D:5001, and dismissed the bad cert warning.

Categories: Uncategorized

Get the #Google #avatar image from an email address in #PHP

Screen Shot 2017-08-12 at 16.49.24

This example uses the service, but a new JSON based API which is a bit more modern than the XML / SOAP based API.

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_USERPWD => “arnoldtest:test123″
$resp = curl_exec($curl);
$avatar = json_decode($resp);

<img src=”<?php echo $avatar->Image ?>”><br>
<?php echo $avatar->Name ?>


The username and password should be substituted with your own username/password which is available at the website.


Categories: Uncategorized

Create cross platform #GUI using #GTK

Screenshot 2018-11-25 at 13.19.03

To skip to the code example, here it is on GitHub;

GTK# is an option that is available under Visual Studio for Mac under Other > .NET > GTK# 2.0, and it allows you to create windows-forms like GUIs that work cross platform, using the .NET Core framework. Above is a simple application that shows the user’s current IP address.

using System;
using System.Net;
using Gtk;

public partial class MainWindow : Gtk.Window
    public MainWindow() : base(Gtk.WindowType.Toplevel)

        WebClient wc = new WebClient();
        var strIP = wc.DownloadString(;);
        label2.Text = strIP;


    protected void OnDeleteEvent(object sender, DeleteEventArgs a)
        a.RetVal = true;

Categories: Uncategorized

Connecting to a #Socks5 proxy from C#


Socks5 is a proxy server that operates on the TCP level, rather than the HTTP/S level, which makes it possible to proxy IP trafic such as email, FTP, voip, etc. Normally, you use a forwarding proxy like Squid, privoxy, or Polipo to bridge the HTTP / Socks5 layer, but you can also interface at socket level from C#

This example is modified from Zahmed on CodeProject, – so credit due there.

So, here’s the modified helper class;

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

* zahmed
* Date 23 Jan 2004
* Socks 5 RFC is available at
namespace LMKR
public class ConnectionException:ApplicationException
public ConnectionException(string message)
:base(message) {}

/// <summary>
/// Provides sock5 functionality to clients (Connect only).
/// </summary>
public class SocksProxy

private SocksProxy(){}

#region ErrorMessages
private static string[] errorMsgs= {
“Operation completed successfully.”,
“General SOCKS server failure.”,
“Connection not allowed by ruleset.”,
“Network unreachable.”,
“Host unreachable.”,
“Connection refused.”,
“TTL expired.”,
“Command not supported.”,
“Address type not supported.”,
“Unknown error.”
public static Socket ConnectToSocks5Proxy(string proxyAdress, ushort proxyPort, string destAddress, ushort destPort)
IPAddress destIP = null;
IPAddress proxyIP = null;
byte[] request = new byte[257];
byte[] response = new byte[257];
ushort nIndex;

proxyIP = IPAddress.Parse(proxyAdress);
{ // get the IP address
proxyIP = Dns.GetHostByAddress(proxyAdress).AddressList[0];

// Parse destAddress (assume it in string dotted format “” )
destIP = IPAddress.Parse(destAddress);
// wrong assumption its in domain name format “”

IPEndPoint proxyEndPoint = new IPEndPoint(proxyIP,proxyPort);

// open a TCP connection to SOCKS server…
Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

nIndex = 0;
request[nIndex++]=0x05; // Version 5.
request[nIndex++]=0x02; // 2 Authentication methods are in packet…
request[nIndex++]=0x00; // NO AUTHENTICATION REQUIRED
request[nIndex++]=0x00; // NO AUTHENTICATION REQUIRED
//request[nIndex++]=0x02; // USERNAME/PASSWORD
// Send the authentication negotiation request…

// Receive 2 byte response…
int nGot = s.Receive(response,2,SocketFlags.None);
if (nGot!=2)
throw new ConnectionException(“Bad response received from proxy server.”);

if (response[1]==0xFF)
{ // No authentication method was accepted close the socket.
throw new ConnectionException(“None of the authentication method was accepted by proxy server.”);

byte[] rawBytes;
// This version only supports connect command.
// UDP and Bind are not supported.

// Send connect request now…
nIndex = 0;
request[nIndex++]=0x05; // version 5.
request[nIndex++]=0x01; // command = connect.
request[nIndex++]=0x00; // Reserve = must be 0x00

if (destIP != null)
{// Destination adress in an IP.
case AddressFamily.InterNetwork:
// Address is IPV4 format
rawBytes = destIP.GetAddressBytes();
case AddressFamily.InterNetworkV6:
// Address is IPV6 format
rawBytes = destIP.GetAddressBytes();
{// Dest. address is domain name.
request[nIndex++]=0x03; // Address is full-qualified domain name.
request[nIndex++]=Convert.ToByte(destAddress.Length); // length of address.
rawBytes = Encoding.Default.GetBytes(destAddress);

// using big-edian byte order
byte[] portBytes = BitConverter.GetBytes(destPort);
for (int i=portBytes.Length-1;i>=0;i–)

// send connect request.
s.Receive(response); // Get variable length response…
if (response[1]!=0x00)
throw new ConnectionException(errorMsgs[response[1]]);
// Success Connected…
return s;

Which is the same as on codeproject, without the username/password requirement, and here’s how it’s called;

byte[] bytesReceived = new byte[1024];
Socket client;
client = LMKR.SocksProxy.ConnectToSocks5Proxy(“”, 9050, “”, 80);
string strGet = “GET /\r\n\r\n”;
var bytes = client.Receive(bytesReceived, bytesReceived.Length, 0);
var page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);


Categories: Uncategorized
%d bloggers like this: