Friday, March 13, 2015
I noticed that the international options on Windows UK English for windows 8 were a bit poor, but I hadn't realised how poor until I started using Duolingo on my Chromebook to learn Swedish (the Chromebook has UK International English keyboard support built in after a fashion, there's a Chromestore install to add it). Here's the fix you need to be able to type all those odd characters like ß and ¿ and «» and if you prefer to type your own curly quotes rather than rely on word to screw you over ( “” & ‘’)
http://www.zolid.com/uk-intl-kb/index.htm
Monday, March 2, 2015
Call Routing with the Siemens n300ip
Call Routing with the Siemens n300ip
We've had one of these DECT IP phone boxes for quite a while. In fact we've had two, but the first one had a 10Meg half duplex interface which caused a lot of grief, which caused us to get the current one.
Why did we get a DECT VOIP phone? Because I was trying to save money of course! A small amount, granted. The idea was that we would drop our phone line and just rely on cable internet with VOIP for our house phone and mobiles to cover any outages. This worked well for 3 years. The calls were cheaper and the quality better, plus we had features on the VOIP line we would have had to pay for with a land line:
- Voicemail to email
- Incoming CLID
- Itemised billing
Plus we could use our number even when we were away from home by logging in with MicroSIP.
Sadly our cable provider kept hiking up the price in increments, and eventually an offer came along that offered more bandwidth with a land line for less money, and with the added bonus of free outbound weekend calls. (I am aware that Virgin did free weekend calls, but the additional cost for the land line was more than we spend on calls).
How to integrate these free calls into the current network? Well the n300ip has dial plans, they are basic but could be configured to route calls through either VOIP or the land line based on the number dialled. However the one thing it doesn't have is any logic related to dates and times. If BT's calls were cheaper than SIPGATE we might forgo the CLID and the itemised e-billing and the network voicemail, but during the week they aren't.
Timed call routing on the cheap
The solution is a nifty script I popped together in python, the script uses libCurl, runs on Linux or Windows with suitable addition of libCurl and need python 3.3 (I leave it as an exercise for the more able to convert it so that it runs on all Python version.
The script runs Saturday morning when our server wakes from its slumber and again on Monday morning.
The call plan fields were captured by using wireshark and then edited using VIM, the script has to do session cookie handling for the password cookie, because I couldn't get libCurl (or Curl for that matter) to persist session cookies.
The functionality of the script is login, upload the call plan and then logout. The parameter is to toggle between enable.txt and disable.txt (the two call plans, enable puts UK landlines beginning 01 and 02 through the fixed line and disable.txt undos this by disabling those call plans). The script is very simple, if you change the call plans it will overwrite them.
Python Code
#!/usr/bin/env python3
import pycurl
from io import StringIO
try:
from io import BytesIO
except ImportError:
from StringIO import StringIO as BytesIO
import email
import argparse
def enable_disable(string):
valid_values = ['enable','disable']
value = str(string)
if not value in valid_values:
msg = "action is either enable or disable, you typed " % string
raise argparse.ArgumentTypeError(msg)
return value
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('action', choices=['enable','disable'] , nargs = 1,
help='either enable or disable, set the dialplan in enable.txt or disable.txt')
args = parser.parse_args()
def CallPlanFileName(x):
return {
"enable" : 'enable.txt' ,
"disable" : 'disable.txt' }[x]
filename = CallPlanFileName(args.action[0])
#print (args.action[0])
## Callback function invoked when body data is ready
def stdout(buf):
# Print body data to stdout
import sys
sys.stdout.write(buf)
# Returning None implies that all bytes were written
## Callback function invoked when header data is ready
def stderr(buf):
# Print header data to stderr
import sys
sys.stderr.write(buf)
# Returning None implies that all bytes were written
body=BytesIO()
header=BytesIO()
c=pycurl.Curl()
c.setopt(c.URL,'http://192.168.XX.XX/login.html')
c.setopt(c.POSTFIELDS, 'language=1&password=XXXX')
c.setopt(c.WRITEFUNCTION, body.write)
c.setopt(pycurl.HEADERFUNCTION, header.write)
c.setopt(c.COOKIEFILE, '') #Make Curl Cookie aware
c.perform()
with open('header.txt','wb') as h:
h.write(header.getvalue())
with open('body.txt','wb') as b:
b.write(body.getvalue())
request_line, headers_alone = ((header.getvalue()).decode('ISO-8859-1')).split('\r\n',1)
mhead = email.message_from_string(headers_alone)
print (mhead.as_string(True))
cookies = mhead['Set-Cookie']
print (cookies)
c.setopt(c.COOKIE, cookies)
with open(filename,'r') as f:
data=f.read()
c.setopt(c.POST,1)
c.setopt(c.POSTFIELDS, data)
c.setopt(c.URL,'http://192.168.XX.XX/settings_telephony_dialplan.html')
c.perform()
c.setopt(c.URL, 'http://192.168.XX.XX/logout.html')
c.perform()
c.close()
exit()
import pycurl
from io import StringIO
try:
from io import BytesIO
except ImportError:
from StringIO import StringIO as BytesIO
import email
import argparse
def enable_disable(string):
valid_values = ['enable','disable']
value = str(string)
if not value in valid_values:
msg = "action is either enable or disable, you typed " % string
raise argparse.ArgumentTypeError(msg)
return value
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('action', choices=['enable','disable'] , nargs = 1,
help='either enable or disable, set the dialplan in enable.txt or disable.txt')
args = parser.parse_args()
def CallPlanFileName(x):
return {
"enable" : 'enable.txt' ,
"disable" : 'disable.txt' }[x]
filename = CallPlanFileName(args.action[0])
#print (args.action[0])
## Callback function invoked when body data is ready
def stdout(buf):
# Print body data to stdout
import sys
sys.stdout.write(buf)
# Returning None implies that all bytes were written
## Callback function invoked when header data is ready
def stderr(buf):
# Print header data to stderr
import sys
sys.stderr.write(buf)
# Returning None implies that all bytes were written
body=BytesIO()
header=BytesIO()
c=pycurl.Curl()
c.setopt(c.URL,'http://192.168.XX.XX/login.html')
c.setopt(c.POSTFIELDS, 'language=1&password=XXXX')
c.setopt(c.WRITEFUNCTION, body.write)
c.setopt(pycurl.HEADERFUNCTION, header.write)
c.setopt(c.COOKIEFILE, '') #Make Curl Cookie aware
c.perform()
with open('header.txt','wb') as h:
h.write(header.getvalue())
with open('body.txt','wb') as b:
b.write(body.getvalue())
request_line, headers_alone = ((header.getvalue()).decode('ISO-8859-1')).split('\r\n',1)
mhead = email.message_from_string(headers_alone)
print (mhead.as_string(True))
cookies = mhead['Set-Cookie']
print (cookies)
c.setopt(c.COOKIE, cookies)
with open(filename,'r') as f:
data=f.read()
c.setopt(c.POST,1)
c.setopt(c.POSTFIELDS, data)
c.setopt(c.URL,'http://192.168.XX.XX/settings_telephony_dialplan.html')
c.perform()
c.setopt(c.URL, 'http://192.168.XX.XX/logout.html')
c.perform()
c.close()
exit()
Call plans
Enable.txt
del_dprno=30&dpr0_0=50000&dpr1_0=0&dpr2_0=&dpr4_0=0&dpr0_1=999&dpr1_1=7&dpr2_1=&dpr4_1=1&dpr0_2=200&dpr1_2=0&dpr2_2=&dpr4_2=2&dpr0_3=101&dpr1_3=7&dpr2_3=&dpr4_3=3&dpr0_4=111&dpr1_4=7&dpr2_4=&dpr4_4=4&dpr0_5=090&dpr1_5=255&dpr2_5=&dpr4_5=5&dpr0_6=90&dpr1_6=0&dpr2_6=&dpr4_6=6&dpr0_7=01&dpr1_7=7&dpr2_7=&dpr4_7=7&dpr0_8=02&dpr1_8=7&dpr2_8=&dpr4_8=8&dpr0_9=0845&dpr1_9=7&dpr2_9=&dpr4_9=9&dpr0_10=0870&dpr1_10=7&dpr2_10=&dpr4_10=10&dpr0=&dpr6=1&dpr1=0&dpr2=&access_code_isdn=&access_code_mode_isdn=0&access_code_voip=&access_code_mode_voip=0&access_code_min_digits=4
disable.txt
del_dprno=30&dpr0_0=50000&dpr1_0=0&dpr2_0=&dpr4_0=0&dpr0_1=999&dpr1_1=7&dpr2_1=&dpr4_1=1&dpr0_2=200&dpr1_2=0&dpr2_2=&dpr4_2=2&dpr0_3=101&dpr1_3=7&dpr2_3=&dpr4_3=3&dpr0_4=111&dpr1_4=7&dpr2_4=&dpr4_4=4&dpr0_5=090&dpr1_5=255&dpr2_5=&dpr4_5=5&dpr0_6=90&dpr1_6=0&dpr2_6=&dpr4_6=6&dpr0_7=01&dpr1_7=7&dpr2_7=&dpr4_7=7&dpr0_8=02&dpr1_8=7&dpr2_8=&dpr4_8=8&dpr0_9=0845&dpr1_9=7&dpr2_9=&dpr4_9=9&dpr0_10=0870&dpr1_10=7&dpr2_10=&dpr4_10=10&dpr0=&dpr6=1&dpr1=0&dpr2=&access_code_isdn=&access_code_mode_isdn=0&access_code_voip=&access_code_mode_voip=0&access_code_min_digits=4
Cron
My server isn't on all the time, it shuts down in the evening and doesn't start up again until everyone is up and about. Initially I was puzzled why my script wasn't having any effect at the weekends. Of course I set the time of the cron job to be midnight Friday and midnight Sunday, both at times my server was asleep. Here's the solution I use:
# Test if it is Saturday @reboot test $(date +\%u) -eq 6 && ( cd $HOME/bin; ./BT_CallPlan enable ) >> ~/BT.log # Test if it is Monday @reboot test $(date +\%u) -eq 1 && ( cd $HOME/bin; ./BT_CallPlan disable ) >> ~/BT.log
Other details:
Our cable provider was Virgin Media, we replaced this with BT Infinity 1
- Virgin (30M down 2.5M up) - usually 20M down 1M up
- BT Infinity 1 (38M down 9.5M up) - so far 34M down and 9M up (much better for telecommuting)
Our VOIP provider is SIPGATE
I sold the Home Hub 5 (£35) and bought an Huawei FTTC terminal adapter/router (which I put custom firmware on).
We use a Buffalo Airstation running OpenWRT (with Asterisk running on it for VOIP), this also provides IPV6 via Hurricane Electric, 2.5 and 5 GHz wireless N and remote access.
When we needed analogues phone lines I used an old BT voyager ADSL router (ADSL disabled) as an ATA (logged into Asterisk as an extension), of course we now have a real analogue line :) .
Virgin Media super Hub (very poor piece of kit), was set to Modem mode due to it's appalling WIFI drop out rates, and general lack of configurable options.
Tuesday, December 3, 2013
I have entered the IPv6 Arena.
My setup was a mash up of configurations from various folks, and connectivity is achieved through a tunnel from the folks at Hurricane Electric.
Before I launch into how I did my configuration: DANGER! DANGER Will Scarlet! - IPv6 is routable, all of it all the time; we have all got lazy sitting behind our NAT routers, not worrying about stuff getting at us directly from the internet. Once you correctly setup one machine on your network as an IPv6 gateway, the chances are that ALL your machines will suddenly be publicly available via IPv6.
You have been warned!
My setup was a mash up of configurations from various folks, and connectivity is achieved through a tunnel from the folks at Hurricane Electric.
Before I launch into how I did my configuration: DANGER! DANGER Will Scarlet! - IPv6 is routable, all of it all the time; we have all got lazy sitting behind our NAT routers, not worrying about stuff getting at us directly from the internet. Once you correctly setup one machine on your network as an IPv6 gateway, the chances are that ALL your machines will suddenly be publicly available via IPv6.
You have been warned!
Howto:
Before you start, your external IP address should be returning ICMP packets if it is pinged. On Virgin Media cable this is turned off by default. You will need to turn it back on or you won't be able to establish the tunnel.
Sign up for an IPv6 Tunnel at Hurricane Electric's website (http://tunnelbroker.net/ or select Free IPv6 Tunnel Broker from the HE home page).
After filling out the new user form, it will ask you to pick your nearest end point. I'm in the UK and I couldn't see any advantage to trying to pick a site in the US for my tunnel, so I picked London. You can only connect one tunnel to your external IP, and once you're setup, all your internal network machines will have public addresses via a routed network. If you delete and setup your tunnel again those addresses will change.
This is where I made my first mistake, I assume you're only just familiar with IPv6 addresses, so read them carefully. My IPv6 address for my router was only 1 digit different from my routed network address, and this got me confused.
The Example configurations will lead you in the right direction, but I actually found them to be less than complete. I'm using Ubuntu 13.10, my IPv6 endpoint has a static network configuration (I am not using Network Manager, all my network configuration is done in /etc/network/interfaces).
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
address 2001:XXXX:YYYA:ZZZZ::2
netmask 64
endpoint 216.66.80.26
local 192.168.x.y
ttl 255
up ip -6 route add default dev he-ipv6
down ip -6 route del default dev he-ipv6
iface eth0 inet6 static
address 2001:XXXX:YYYB:ZZZZ::1
netmask 64
My mistake initially was not to realise that A and B were different :D
When you've setup your tunnel (you may stop there if only want one machine on your network to have IPv6 access to the internet), you will want to add two more things. Your internal network adapter will need an IPv6 address from the "routed IPv6" network (not the network that's wasted on your tunnel). And then you will need to advertise your route.
The beauty of IPv6 is that it's all very self configuring, apart from a few niggles.
Once the tunnel's up, and the internal network interface has a "routed" address on it, you will need to advertise it to your local net. Install RADVD. It doesn't need any configuration, but here's where complication sets in: RADVD can advertise the IPv6 DNS, but Windows will only get IPv6 DNS from DHCPv6. Basically you end up setting up DHCPv6 just to advertise DNS for windows machines.
If your router also happens to be a webcache you can skip the routed address and RADVD in favour of http proxying over IPv4 and getting the cache server to do all the IPv6 magic.
My next trick is to try and make an all IPv6 machine that can still talk to the IPv4 internet.
This is where I made my first mistake, I assume you're only just familiar with IPv6 addresses, so read them carefully. My IPv6 address for my router was only 1 digit different from my routed network address, and this got me confused.
The Example configurations will lead you in the right direction, but I actually found them to be less than complete. I'm using Ubuntu 13.10, my IPv6 endpoint has a static network configuration (I am not using Network Manager, all my network configuration is done in /etc/network/interfaces).
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
address 2001:XXXX:YYYA:ZZZZ::2
netmask 64
endpoint 216.66.80.26
local 192.168.x.y
ttl 255
up ip -6 route add default dev he-ipv6
down ip -6 route del default dev he-ipv6
iface eth0 inet6 static
address 2001:XXXX:YYYB:ZZZZ::1
netmask 64
My mistake initially was not to realise that A and B were different :D
When you've setup your tunnel (you may stop there if only want one machine on your network to have IPv6 access to the internet), you will want to add two more things. Your internal network adapter will need an IPv6 address from the "routed IPv6" network (not the network that's wasted on your tunnel). And then you will need to advertise your route.
The beauty of IPv6 is that it's all very self configuring, apart from a few niggles.
Once the tunnel's up, and the internal network interface has a "routed" address on it, you will need to advertise it to your local net. Install RADVD. It doesn't need any configuration, but here's where complication sets in: RADVD can advertise the IPv6 DNS, but Windows will only get IPv6 DNS from DHCPv6. Basically you end up setting up DHCPv6 just to advertise DNS for windows machines.
If your router also happens to be a webcache you can skip the routed address and RADVD in favour of http proxying over IPv4 and getting the cache server to do all the IPv6 magic.
My next trick is to try and make an all IPv6 machine that can still talk to the IPv4 internet.
Tuesday, January 22, 2013
We got hacked!
The house phone is an Asterisk PBX and our service provider is Sipgate. They informed me last Thursday that our system was compromised, due to some unusual call activity, but no more info than that. So we changed all our passwords for our SIP account. FAIL.
Saturday and Sunday and Monday saw more calls made; Sipgate support don't work weekends and we didn't notice until the call credit low warning hit my inbox on Monday evening. Another email to Sipgate, this time they tell us that our Asterisk PBX is making the calls, and no we can't have the money back. A quick check and lo! I allowed external guest extensions to connect to the PBX, and I didn't restrict the IP addresses of registering devices. DAMN! Ah well, you live and learn.
Fortunately Sipgate charge up front, and we only put £10 on at a time. The bad guys made off with £4-ish of calls, we don't have auto pay setup and we do get an alarm when the credit goes below £5. All told the most we can loose is £10 and this saves us £15 every month (no line rental).
So a quick crash course in securing Asterisk, and a dollop of iptables firewalling for the PBX and we're back up and running.
The house phone is an Asterisk PBX and our service provider is Sipgate. They informed me last Thursday that our system was compromised, due to some unusual call activity, but no more info than that. So we changed all our passwords for our SIP account. FAIL.
Saturday and Sunday and Monday saw more calls made; Sipgate support don't work weekends and we didn't notice until the call credit low warning hit my inbox on Monday evening. Another email to Sipgate, this time they tell us that our Asterisk PBX is making the calls, and no we can't have the money back. A quick check and lo! I allowed external guest extensions to connect to the PBX, and I didn't restrict the IP addresses of registering devices. DAMN! Ah well, you live and learn.
Fortunately Sipgate charge up front, and we only put £10 on at a time. The bad guys made off with £4-ish of calls, we don't have auto pay setup and we do get an alarm when the credit goes below £5. All told the most we can loose is £10 and this saves us £15 every month (no line rental).
So a quick crash course in securing Asterisk, and a dollop of iptables firewalling for the PBX and we're back up and running.
Friday, January 11, 2013
Three Challenge
Apparently 3/Three don't accept that I own the phone. Worrying; I suspect this is true for all mobile phone companies. Because I don't have the purchase receipt or the details of where it was originally bought, they won't accept that I am the owner. So what?
Well if the original owner phoned them up, read out the IMEI and said the phone had been stolen, they would block the phone. Fortunately they didn't register it, but I can't register it either.
My other motivation is that 3 will unlock the phone for £15.53 (apparently) whereas all the other places want about £24. I shan't be using 3 once the phone is unlocked ...
The system beggars belief to my mind; they sent me a SIM to my postal address, they can see from their network that I am calling from my handset (with the IMEI), you'd think they'd want to encourage people to register. At worst they've got some personal details they can bundle up and sell on (email, phone number address etc.) at best they've got that plus marketing data about the second hand market for their handsets, something they probably need to know about if they want to sell more new handsets.
Hopefully the seller will be forth coming with the store and the date of purchase which can then be used to confirm to three that I actually own the handset now and so it can be registered to me.
(and then promptly unlocked and switch to Giff Gaff :D).
Well if the original owner phoned them up, read out the IMEI and said the phone had been stolen, they would block the phone. Fortunately they didn't register it, but I can't register it either.
My other motivation is that 3 will unlock the phone for £15.53 (apparently) whereas all the other places want about £24. I shan't be using 3 once the phone is unlocked ...
The system beggars belief to my mind; they sent me a SIM to my postal address, they can see from their network that I am calling from my handset (with the IMEI), you'd think they'd want to encourage people to register. At worst they've got some personal details they can bundle up and sell on (email, phone number address etc.) at best they've got that plus marketing data about the second hand market for their handsets, something they probably need to know about if they want to sell more new handsets.
Hopefully the seller will be forth coming with the store and the date of purchase which can then be used to confirm to three that I actually own the handset now and so it can be registered to me.
(and then promptly unlocked and switch to Giff Gaff :D).
Thursday, January 10, 2013
My new year's resolution will be to post more to the blog :D
So, I have bought a new phone and I may have become an early adopter. The phone is the Xperia J (aka st26i), it's locked to three at the moment, and so not in use. I have a free three sim, I've registered it with them and I'm waiting on unlock codes. In the mean time I will be taking it apart and posting photo's.
Three will unlock the handset for a fee (it was originally bought as a pay-as-you-go handset). However you have to register the handset with them. Currently I'm hoping that they will accept paypal as proof of purchase, if not I'm reliant on getting the original purchase receipt from the original owner.
Handset looks good, nice weight, great sound when used with my Nokia Lumia 920 headphones.
Can't wait to get it unlocked so I can use it with my regular network, also looking forward to removing all the Three network branding on the device.
So, I have bought a new phone and I may have become an early adopter. The phone is the Xperia J (aka st26i), it's locked to three at the moment, and so not in use. I have a free three sim, I've registered it with them and I'm waiting on unlock codes. In the mean time I will be taking it apart and posting photo's.
Three will unlock the handset for a fee (it was originally bought as a pay-as-you-go handset). However you have to register the handset with them. Currently I'm hoping that they will accept paypal as proof of purchase, if not I'm reliant on getting the original purchase receipt from the original owner.
Handset looks good, nice weight, great sound when used with my Nokia Lumia 920 headphones.
Can't wait to get it unlocked so I can use it with my regular network, also looking forward to removing all the Three network branding on the device.
Tuesday, December 18, 2012
New stylus!
So I picked up a new stylus for my Nexus. It's truly a wonderful thing. I am sooo pleased with it I had to hammer out this short post. A decent stylus & Grafitti is an amazingly fast way to enter text. Truly so much quicker than picking keys from the touch keyboard. Which stylus? This one:
from Amazon. The tip is sponge, but covered in a knit cover. It glides! & the price is FAB!
Subscribe to:
Posts (Atom)