Pages

Sunday, 27 July 2008

Trouble uploading files to wordpress

I had problems uploading files to wordpress hosted at the local machine. Conditions are:

  • Firefox 3.0

  • Flash 9.0

  • Local squid proxy 2.7.STABLE3

  • Firefox setup for using local proxy except from accessing local machine. This makes no difference at all.

  • Environment variable http_proxy set to http://127.0.0.1:8080/



The result of trying to upload images to wordpress was "HTTP Error". A sample wireshark capture of the failed request looks like this:

Request:


POST http://localhost/wordpress/wp-admin/async-upload.php HTTP/1.1
Host: localhost
Pragma: no-cache
Accept: */*
Proxy-Connection: Keep-Alive
User-Agent: Shockwave Flash
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 40861
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------5ce16f6dfa7a



Response:


HTTP/1.0 417 Expectation failed
Server: squid/2.7.STABLE3
Date: Sun, 27 Jul 2008 09:31:50 GMT
Content-Type: text/html
Content-Length: 1507
Expires: Sun, 27 Jul 2008 09:31:50 GMT
X-Squid-Error: ERR_INVALID_REQ 0
X-Cache: MISS from XXXXX.XXXX.XXXX
X-Cache-Lookup: NONE from XXXXX.XXXX.XXXX:3128
Via: 1.0 XXXXX.XXXX.XXXX:3128 (squid/2.7.STABLE3)
Connection: close

[...]
A page saying:
ERROR: The requested URL could not be retrieved
[...]



It is obvious that flash plugin is used to perform the upload and it is using the proxy. It does a request with an "Expect:" header and for an (unknown to me) reason the expectation fails because of the squid proxy.

Disabling proxy in firefox, restarting it and bypassing cache doesn't help. The problem lies in that the flash plugin uses the http_proxy environment variable to determine the proxy.

Solution:
Unsetting http_proxy in a terminal and starting firefox from there solves the problem.

Friday, 18 July 2008

Routes with greater prefix and Proxy ARP ~= IP Mobility

Inside an Autonomous System, it is possible to move a machine inside a network, keeping its IP address even though it goes to a network segment that doesn't serve the corresponding Network.

Something like this:

RouterA -------- Network Segment
|
Host A (10.1.0.2/24, GW: 10.1.0.1)


It is possible to move Host A to another network segment, lets say to interface FastEthernet of RouterB. Of course this would require address and possibly other configuration changes to Host A. Changin the IP address of a server is not always a good idea (tm).

Lets say that we move Host A to interface FastEthernet of Router B. Supposing that a routing protocol is setup and works in the Autonomous System, Host A may keep its IP address by configuring RouterB (cisco commands):

RouterB(config)# ip route 10.1.0.2 255.255.255.255
FastEthernet 0/1

RouterB(config)# interface FastEthernet 0/1
RouterB(config-if)# ip proxy-arp # This is the default

RouterB(config)# router eigrp 1
RouterB(config-router)# redistribute static

RouterA(config)# interface FastEthernet 0/1
RouterA(config-if)# ip proxy-arp


This will work because:

  • Whenever Host A tries to reach a host in its subnet (ARP request), Router B will respond with its mac address. This is what Proxy ARP does.

  • All routers within the A.S. will learn the 10.1.0.2/32 route. Even Router A will prefer to use this one instead of the directly connected 10.1.0.0/24 since it has a longest preffix (routing table lookups are longest matching preffix lookups)

  • Since Router A will also learn this route and since it has Proxy ARP enabled, it will respond to ARP requests for 10.1.0.1 with its address

Wednesday, 16 July 2008

Maemo internet connection from command-line

Using OS2008/Diablo in maemo (tested in N800 but should work elsewhere) it is possible to initiate (and terminate) an Internet connection from the command line. This is useful for automating tasks.

The whole thing is easily done using some dbus functionality that is available from running services.

To initiate a new connection:


dbus-send --system --print-reply --type=method_call \
--dest=com.nokia.icd \
/com/nokia/icd com.nokia.icd.connect \
string:"Connection Name" uint32:0



Where "Connection Name" is the connection name as it is listed in the UI when selecting where to connect to. It can be a wireless connection, a GPRS connection via bluetooth, a PAN connection or whetever will be supported in the future.

To terminate the connection:


dbus-send --system \
--dest=com.nokia.icd \
/com/nokia/icd_ui com.nokia.icd_ui.disconnect \
boolean:true