Some random thoughts on p2p social networking

I’m beginning to wonder if p2p social networking software will ever take off for the general populace or even be much of a concern.

One of the reasons I feel that places like Myspace let people without the know-how or money easily setup their own web presence. While there were places like Geocities and Angelfire, they still required design work and weren’t painless to update.

On top of this, we have the ever increasing sharing of pictures and now videos. These aren’t easily shared via other p2p methods like email as each host can have wildly different message size constraints and there’s still the bandwidth variable for the receiving party. They probably don’t want to wait for a stretch for one video laden message to download while still needing to get the one with the cancer test results. A link is far simpler and faster to share, but this requires a host somewhere and brings us back to the know-how and money issue.

More still we have the address book nature of places like Facebook. As long as I have someone’s name and they use it, I can find them. While this can be done with services like Google, Bing and the ol’ phonebook, there is significant leg and guess work that to even guess if we have the correct person. Social networks take a lot of that guesswork out of this by sharing some details like a name, a picture and maybe some other auxiliary information like school and town.

One of the central problems I see is that p2p social networking is trying to replace the post office system that social networks like Facebook are. Or in another analogy, they are trying to get two fingers to touch with each being on a different person, drunk, blind-folded, starting from opposite sides of the planet, and not giving any information to either party on who they are trying to connect with or their location.

IPv6 in the home and me

Last November we moved from a rental home into a home of our own. Unfortunately, the old woman before us never had cable television or internet and so we had to wait a month before the ISP was able to dig in a line and hook us up. Now that we have internet, I’ve finally been able to resurrect my network.

While our ISP does have 6RD, I’m a huge fan of Hurricane Electric’s TunnelBroker.net. I find it easy to use and I don’t need to worry about changing ISP and keeping the same address range.

From before the move I had a dual-stack with an old laptop working as the IPv6 tunnel/router/firewall. (Because I don’t yet have a PCMCIA ethernet card and it’s so old I can’t get vlan trunking working so it has to function behind my Buffalo router/AP.) Now that we have internet, I just powered it on, ran “sudo ifup he-ipv6”, and voila! IPv6 was up and running.

What to do with 2^64 addresses at my disposal? Well, one thing I’m wanting to get working is getting my media anywhere I have a cellular signal and data. This is a problem as my phone only seems to support IPv4 on cellular networks and I don’t really want to go the dynamic DNS route as it seems too…archaic.

IPv6 router using TunnelBroker

/etc/network/interfaces

auto he-ipv6
iface he-ipv6 inet6 v4tunnel
	pre-up wget -q --no-check-certificate -O - 'https://ipv4.tunnelbroker.net/ipv4_end.php?ip=AUTO&pass={PASSWORD}&apikey={APIKEY}&tid={TUNNELID}'
	address {LOCAL_TUNNEL_IPV6}
	netmask 64 endpoint {HE_ENDPOINT}
	up `ip -6 route add default via {HE_TUNNEL_ENDPOINT_IPV6} dev he-ipv6`
	up `echo 1 > /proc/sys/net/ipv6/conf/all/forwarding`
	down `echo 0 > /proc/sys/net/ipv6/conf/all/forwarding` 

Quick and dirty Powershell + Growl host watch

Needing a quick and dirty growl notification to know when a person restarted their computer, so I wrote up this originally one line script.

. '\libs\growl\Send-Growl 3.1.ps1';	#http://poshcode.org/1464
					#Might need to modify the file a little.

$str = @("down", "up");
$last_ds = $false;
while(1) {
	$new_ds = Test-Connection TargetHost -Quiet -Count 2;
	if($new_ds -ne $last_ds) {
		Send-Growl -Caption "Watchtower" -Message ("TargetHost is {0}" -f $str[$new_ds]);
	}
	$last_ds = $new_ds;
	sleep 5;
}

 
Just copy and paste in ISE, modify and away you go!
 

Bonus points protip: Run in the background.

start-process powershell @("Hidden", "-File" "\path\to\above\script.ps1") -WindowStyle Hidden

“A little political” or “I’ll only be occupying the toilet.”

I recently saw the “We are the 99 Percent” blog on Tumblr. Which if we’re going by “millionaire” status, should be more like “We are the 96.777777 percent”.

Reading the about/introduction page, I have to say that some of that applied to me. Then I attended some Financial Peace University classes. I started planning my finances better, deliberately putting aside money for rainy days, cancelling extra services like my cable television, not eating out so much, etc. These things really started to come to head after getting married. We were able to be quite comfortable month to month even while paying down our debts.

While my wife and I have been very blessed and have not had the hardships many people have put on “We are the 99 Percent”. I would like think that our planning and our hard work have played a significant role in where our lives are today.

So without further delay, my “I am the 1 percent” contribution.

I never finished the two year Associate in Applied Science degree at the local Community College I was working towards.
My wife had several thousand dollars in student loans when we married, I had some credit card debt.
I never owned a brand new car.
I am married to a wonderful woman.
I have a beautiful daughter and another child on the way.
I have a job where I enjoy the work with decent pay.
My wife and I share a car.
My wife and I both have a smart-phones.
My wife and I have one television.
My wife and I have no paid television service (cable/satellite) unless Netflix counts.
I have an Xbox 360 Slim.
My wife and I rent a home.
My wife and I have no credit cards.
My wife and I have a 3 months of living expenses in savings.
My wife and I now have no debt other then our upcoming home mortgage.
We are in our mid-twenties.

I am the 1 percent.

There are of course many other things that could be on this list, but to think of the all would just push this entry back.

IPv6 range/subnet calculater for powershell

From what I can tell, there aren’t many…if any, IPv6 address range calculators. While I read it is recommended that you use the entire /64 block, I don’t think it’s always necessary to do so. Besides, what happens when you want to route only a portion of the block to one place?

Example usage:

ipv6range.ps1 2001:470:1f10:60::10 64 | ft ipaddress*
ipv6range.ps1 2003:5:1f:fa0::10 104 | ft ipaddress* #ipv4 /8 equivalent
ipv6range.ps1 2003:5:1f:fa0::10 112 | ft ipaddress* #ipv4 /16 equivalent
ipv6range.ps1 2003:5:1f:fa0::10 120 | ft ipaddress* #ipv4 /24 equivalent
ipv6range.ps1 2003:5:1f:fa0::10 124 | ft ipaddress* #ipv4 /28 equivalent

….and the code….

param(
    [net.ipaddress]$Addr,
    [int]$netmask = 64,
    [switch]$ForceListing

)

if($Addr.AddressFamily -ne 'InterNetworkV6') { throw "`$Addr must be a valid IPv6 address."; }

<#
Create a subnet mask based on a CIDR input.
#>
function subnet {
    param(
        [int]$netmask
    )

    if($netmask -gt 128) { throw "`$netmask cannot be greater than 128"; }

    $mask = (@($true) * $netmask) + (@($false) * (128-$netmask));
    return New-Object Collections.BitArray @(,$mask);
}

<#
Convert a BitArray into a byte array for easy conversion into an IPAddress.
#>
function bit2byte {
    param(
        [Collections.BitArray]$bitArray
    )

    for($i = 0; $i -lt $bitArray.length; $i+=8) {
        [convert]::ToByte([string]::Join("", ([string[]][byte[]]($bitArray[$i..($i+7)]))), 2)
    }
}

<#
convert an ip into a BitArray for easy bitwise operations.
#>
function ip2bit {
    param([net.ipaddress]$addr)

    $b = $addr.GetAddressBytes();
    $bits = @();
    foreach($a in $b) {
        $t = [convert]::ToString($a,2).padleft(8,"0") #[7..0];
        $bits += [string]::join("",$t);
    }
    $nbits = ($bits | %{[char[]]$_} | %{[bool]::Parse("$_".replace("1","true").replace("0","false"))});
    return New-Object collections.bitarray @(,$nbits)
}

<#
Increment an ipv6 address.
#>
function inc {
    param([net.ipaddress]$addr)

    $b = $addr.GetAddressBytes();

    for($i = $b.length-1; $i -ge 0; $i--) {
        if($b[$i] -gt 254) { continue; }
        $b[$i]++;
        break;
    }
    New-Object net.ipaddress @(,$b);
}

<#
Decrement an ipv6 address.
#>
function dec {
    param([net.ipaddress]$addr)

    $b = $addr.GetAddressBytes();

    for($i = $b.length-1; $i -ge 0; $i--) {
        if($b[$i] -eq 0) { continue; }
        $b[$i]--;
        break;
    }
    New-Object net.ipaddress @(,$b);
}

$ipArr = new-object collections.bitarray @(,(ip2bit $Addr.GetAddressBytes()))

$netBits = New-Object collections.bitarray @(,(subnet $netmask))
$hostBits = (New-Object collections.bitarray $netBits).Xor((New-Object collections.bitarray 128, $true)) #.xor((New-Object collections.bitarray 128, $true))

$netId = New-Object net.ipaddress @(, (bit2byte (New-Object collections.bitarray $ipArr).And($netBits)));
$netBcast = New-Object net.ipaddress @(, (bit2byte (New-Object collections.bitarray $ipArr).Or($hostBits)));

$numHosts = [math]::Pow(2, ($hostBits | ?{$_} | measure).count)

if($numHosts -gt 256 -and !$ForceListing.ispresent) {
    #well, if we have more than this, just output the (ipv4 equivalent) network id and broadcast address.
    $netId
    $netBcast
} else {
    Add-Member -PassThru -Force -InputObject $netId -MemberType NoteProperty -Name IsUsable -Value $false;
    try {
        $lastAddr = $netId;
        for($i = 0; $i -lt $numHosts-2; $i ++) {
            $lastAddr = inc $lastAddr
            Add-Member -PassThru -Force -InputObject $lastAddr -MemberType NoteProperty -Name IsUsable -Value $true;
        }
    } catch {}
    Add-Member -PassThru -Force -InputObject $netBcast -MemberType NoteProperty -Name IsUsable -Value $false;
    #$res
}

Notes:

  • Not commented well. RTCFA (read the code for answers)! >:(
  • Only increments despite there being a decrement function.
  • If the number of host addresses is less then 256, it will always display the complete listing.

There should be a lesson in here…somewhere

Well things turned for the worst this past weekend. I was upgrading my server from Ubuntu 9.10 to 10.10 and it failed. Thankfully I had made backups of the databases…or not! I’m exactly not sure what happened, but my best guess is that the disk I keep my site files on (html, php, etc.) was unmounted before I did the backups. So the directory/disk I thought I was copying to wasn’t. 🙁

A very sad, sad day. Now either I need to poke through my Facebook account to grab all my old posts, or just say “screw it” and start again from scratch.