Sunday, January 17, 2021

MIPS gcc for windows prebuilt

 Hard to find it via google. Here's MIPS-gcc for windows. 

I can do no better than give this link, which works as of 2021 and will do so until mentor take it down, although it's been up since 2013..


https://sourcery.mentor.com/public/gnu_toolchain/mips-sde-elf/mips-2013.11-37-mips-sde-elf.exe


If this link is dead, look for 'mips-2013.11-37-mips-sde-elf.exe'


Tuesday, May 26, 2020

Running Pi-Hole on an Orange Pi Zero (256MB RAM) without crashing

Default setting for Pi-Hole causes it to run out of ram on a 256MB system such as the ultra-cheap Orange Pi Zero,

Suggested changes:
edit fastcgi-php to run less cgi processes e.g.
nano /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
and change
 "PHP_FCGI_CHILDREN" => "2",
(from 4 child processes)

also change 
nano /etc/php/7.3/cgi/php.ini
and set
memory_limit = 64M
(instead of 128M)

That should do it

Thursday, October 4, 2018

VMWare guest suddenly can't ping host (but can reach LAN/WAN) - SOLVED! (Linux VM on Windows 7 host)

Scenario:

  1. Laptop running VMWare, single Gig-E port on laptop onto LAN/WAN. The usual.
  2. VMWare setup working fine since forever, VMs bridged to LAN and hence work like an independent network interface with their own MAC/IP etc. Yay.
  3. Suddenly one day out of the blue the fecking thing only half-works; 
    1. the VM can reach the LAN and internet 
    2. Other boxes on the  LAN can reach the VM just fine
    3. ...but the VM can't ping/etc the host machine, or vice versa.
  4. W.T.F!? Has worked since forever!
SOLUTION:
Running Wireshark (or similar network sniffer) switches the gig-e interface into promiscuous (i.e. not MAC-filtered) mode, which is all fine and dandy, and when capture stops, as you'd expect, Wireshark switches it off again...

If you run arping from the VM to the host, it fails, but it starts working as soon as you begin packet capture in wireshark - and stops as soon as you stop..

It appears (which is somewhat logical) that VMWare lan bridge stuff requires the i/f in promiscuous mode and Wireshark turning it off at the end of a capture breaks the connectivity from VM to host somehow.

Solution: After using wireshark, in the Windows network adapter panel, disable and re-enable the interface. This resets it back to a fully working (with VMWare) condition.


If that stopped you screaming at your computer - you're welcome!

Saturday, August 6, 2016

DFPlayer MP3 module - high quiescent power consumption and clicks when power applied and removed - FIX!

The DFPlayer is a great little MP3 player module at a fantastic price, but there's a really odd design choice; it has a high quiescent current of about 25ma, requiring you to cut the power to it with a PFET when not in use, and, worse, it suffers from power on/off clicks when you do that.

The schematic of the module is basically the reference design from here (the mp3 player chip vendor's page)
http://www.yxin18.com/kp/2015102450.html
and they're using a bog-standard no-name 8-pin 8002 audio amplifier chip (in this case a class AB one, not a PAM8002 which is class D, but hey, the whole board costs about a buck), anyway it's a BTL amplifier, so + and - are both floating at VCC/2 when no sound is playing.

This requires the amp to put a little care into avoiding pops/clicks when power is applied and removed, and the 8002 designers kinda did this already; here's a generic 8002 amp datasheet;
http://thaieasyelec.com/downloads/EFDV308/HXJ8002_Miniature_Audio_Amplifier_Datasheet.pdf

They have both a SHUTDOWN pin and a bias cap so that the speaker ramps up and down subsonically... 

Anyway looking at the DFPlayer board I see they just have the SHUTDOWN pin (pin 1) wired to GND, i.e. always-on, via a 0-ohm resistor (if you look next to pin 1 on the 8-pin chip on a generic DFPlayer module, there's a "000" resistor next to it).
What's totally bizarre is that the MP3 player chip is set up to output a "BUSY/IDLE" signal (comes out on pin 1 of the DFPlayer module) which is the right polarity and basically ideal to drive the SHUTDOWN on the 8002 amplifer.

..and lo and behold, if you pull off the 0-ohm resistor and wire pin 1 of the 8002 straight to the BUSY output pin of the module - you get a double win - no more power on/off clicks at all (now totally silent) AND halves the quiescent power consumption of the module (takes about 10mA off it).

WTF? No idea why they didn't do this... Anyway, there's your easy fix...  now you can gate the power to the entire module (still necessary, it sucks down >10ma even when not doing anything) but at least it doesn't click when you do it....

EDIT: Aaaaahhh.. they did, it's an option. Looking at the underside of the board there's  unpopulated pads opposite the 0R resistor; remove the 0R and put it on the other pads and it connects SHUTDOWN to BUSY :-)


DFPlayer MP3 module - high quiescent power consumption and clicks when power applied and removed - FIX!

The DFPlayer is a great little MP3 player module at a fantastic price, but there's a really odd design choice; it has a high quiescent current of about 25ma, requiring you to cut the power to it with a PFET when not in use, and, worse, it suffers from power on/off clicks when you do that.

The schematic of the module is basically the reference design from here (the mp3 player chip vendor's page)
http://www.yxin18.com/kp/2015102450.html
and they're using a bog-standard no-name 8-pin 8002 audio amplifier chip (in this case a class AB one, not a PAM8002 which is class D, but hey, the whole board costs about a buck), anyway it's a BTL amplifier, so + and - are both floating at VCC/2 when no sound is playing.

This requires the amp to put a little care into avoiding pops/clicks when power is applied and removed, and the 8002 designers kinda did this already; here's a generic 8002 amp datasheet;
http://thaieasyelec.com/downloads/EFDV308/HXJ8002_Miniature_Audio_Amplifier_Datasheet.pdf

They have both a SHUTDOWN pin and a bias cap so that the speaker ramps up and down subsonically... 

Anyway looking at the DFPlayer board I see they just have the SHUTDOWN pin (pin 1) wired to GND, i.e. always-on, via a 0-ohm resistor (if you look next to pin 1 on the 8-pin chip on a generic DFPlayer module, there's a "000" resistor next to it).
What's totally bizarre is that the MP3 player chip is set up to output a "BUSY/IDLE" signal (comes out on pin 1 of the DFPlayer module) which is the right polarity and basically ideal to drive the SHUTDOWN on the 8002 amplifer.

..and lo and behold, if you pull off the 0-ohm resistor and wire pin 1 of the 8002 straight to the BUSY output pin of the module - you get a double win - no more power on/off clicks at all (now totally silent) AND halves the quiescent power consumption of the module (takes about 10mA off it).

WTF? No idea why they didn't do this... Anyway, there's your easy fix...  now you can gate the power to the entire module (still necessary, it sucks down >10ma even when not doing anything) but at least it doesn't click when you do it....




Thursday, August 4, 2016

Seriously optimizing power consumption on a STM8F103F3P6 "minimum system board"

You know, these things, they're all over EBay

Anyway, when running off 3.3v (not using the USB connector) and putting them into the lowest power mode I could find (ACTIVE-HALT using the AWU to wake it up once a second) I was still seeing several milliamps power consumption; was expecting a hundred microamps or thereabouts;

To achieve this;
a) (Obviously) Remove the "PWR" led (or take off the resistor on the underside) to save a few mA
b) Remove the 3.3v regulator(!!) this was the main problem; was leaking about 2.2mA when back-powered with 3.3v

Down to about 178uA now (with internal main voltage regulator (MVR) on) running off internal LSI clock, which is nicely just under the datasheet's quoted 200uA.

With the MVR off in halt and the flash powered down (and again waiting up with AWU at 1hz to do practically nothing), i.e.
FLASH_SetLowPowerMode(FLASH_LPMODE_POWERDOWN);
CLK_SlowActiveHaltWakeUpCmd(ENABLE);

we're down to 38uA!!! Sweeeet!



Friday, January 22, 2016

Found: bug in Tinysidplay V0.94 playing Martin Galway music (and others probably)

Bug in TinySidPlay 0.94

The linux source for this version comes with a .CPP version and a separate .C version (the latter is what the makefile uses). There's a couple of glaring bugs in the 6510 emu which means it can't play several bits of music, e.g. Martin Galway's stuff.  This is fixed in the CPP version but it's hard to spot;
the error is in the "CPX" and "CPY" instruction emulations in sidengine.c;

at both "case cpx:" and " case cpy:" (around line 950ish) the "setflags(FLAG_C, a >= bval);" is setting the carry flag based on comparing with A not X, so change it to
setflags(FLAG_C, x >= bval);
..same with "cpy" just below it, change to
setflags(FLAG_C, y >= bval);

and workie!

Thursday, October 22, 2015

Modifying YDS-812 buck converters

These buck converters are great; readily available on Ebay for about $4 a pop.
YDS-812DC 20V-45V to DC 12V 8A Synchronous Adjustable Step-down Power Modulebuck DC-DC 20-45V to 12V 0.7V-23V 8A Step-down Power Supply Module YDS-812 Japan

Wins:

  • Well heatsinked, well made
  • Synchronous  for higher efficiency
  • Easily modified in useful ways
Official datasheet is here - however practical experience actually you can ignore quite a lot of it :-)
The over-current shutdown doesn't seem to work very well (I pulled 13A @ 5v out of one) and the minimum voltage spec is also pessimistic - when modded you can run them on lower voltage inputs. YMMV of course.

The main control chip is the Texas Instruments LM2727
The fets are 52N06 fets

Firstly; you MUST add electrolytic capacitors on the input and outputs or they just don't work; I put e.g. 1000uf (e.g. 35v) on the input and 2500uf on the output. You should use low-ESR caps.

Adjusting output voltage

On the PCB, VR1 is 1k,  VR2 is composed of an 18k (on the left) and a 1k (right) in series = 19k.
The controller wants to see 0.6v on the FB input, so the default divider values of 1k & 19k gives you 
12v 'input' (buck output) = 0.6v output (feedback to chip). 

The resistor divider calc is of course (19k+1k)/1k * 0.6v =12v at Vout  

When modding this board for lower voltage output I find it easiest to piggyback an extra 0402 resistor on top of the 18k one 

Here's the datasheet sample schematic that roughly matches what we have on the board (minus the 5v regulator, FET driver and other bits and pieces)...

Soft on/off

The transistor just above VR1 on the board is an internal on/off switch (not sure when it's used), but if you solder a wire onto the right hand side pin of it (according to the above pic) you get access to /SD; pull this low and the buck switches off.  Note it has an extremely weak (microamps) 5v pullup on-chip.



Saturday, January 3, 2015

How to fix Crucial V4 SSD I/O errors

I use a 32GB Crucial V4 SSD for the OS drive of my home theater PC; it's not a great drive but it works.. well, up until today, when an unexpected powerdown corrupted it. I tried to reimage the drive (I use "DD" under linux) but I got a bunch of IO errors writing to the SSD. DOH!  Normally I'd bin the drive and buy another one (hint; not a Crucial drive) but this time I found a fix...

If you re-flash the drive's firmware (using the bootable usb stick image found here ) it cautions in the docs here "!ALL DATA WILL BE LOST!"   ...well, y'know actually that sounds ideal...

And lo! Even though my drive was already running the latest firmware, the tool allows you to reflash it anyway, and bingo - twenty seconds later a completely blank SSD with no hard errors.

Happy new year!

Monday, July 7, 2014

Powering a lot of WS2812B LEDs from a 12V car battery - try this!

Ok so let's say you need to power a shit-load of WS2812B LED strips from e.g. a car battery.
You need to convert ~12v to 5v and you need a lot of current.
You also want high efficiency, and you'd like to be able to power them down completely to avoid the ~1ma-per-led quiescent current..

While perusing buck converters, I came across this, and was immediately curious... It's about $10 a pop.

http://www.prodctodc.com/dc-1014v-to-255v-15a-buck-converter-peak-20a-high-current-power-supply-p-121.html
also on Ali-express
http://www.aliexpress.com/item/5-PCS-LOT-DC-Buck-Converter-15A-10-14V-to-2-5-5V-Peak-20A-High/558859436.html

Rated at 20Amps, ideal for a large car/deep cycle lead-acid battery.

Seems like rather a fancy module on there, no? Well.. it sure is!

Eyeballing the part number it's actually a really high quality DC-DC converter module; the Artesyn "SIL40c-12sADJ-VS", now obsolete.
http://www.artesyn.com/power/assets/lf_sil40c_1208906885_techref.pdf

The module is actually rated at 40A continuous output with 92% efficiency, low ripple, and all the bells and whistles you could want.   Datasheet mentions 18.5A input (@12v) = 222W in and 40A @5V = 200W out, which is 90%, so only about 20W dissipation at full power.  Very nice.  Spec-wise this is far superior to all the other cheapo DC-DC buck converters from china, and a very good price at that.
The modules also support 'current sharing' as well as remote on/off, it's also _very_ well regulated to handle very rapid surges in current (i.e. all your LEDs going from off to on!), and so on.

Quite possibly by just beefing up the PCB traces a little with some thick wire one could get high efficiency car battery->5v @ 40A very inexpensively (about $10 a pop).

Looks very promising!

Caveat: It's possible the modules they're using are rejects but we'll see. They may just available b/c the module's been discontinued.

The three chips on the underside of the host board are a slight mystery; the two on the left look like reverse-polarity protection diodes on the input [update: no, they're P-FETs, only 2mv drop!]  (which I plan to bypass, not wasting my precious juice on them), the other in the middle... not sure yet [update: LM393 comparitor]  The module datasheet implies it's basically ready-to-rock as it comes, with only external smoothing caps.

Note that the module sheet suggests 2000uf output caps for 5v and these have only about 1200-ish, but should be ok.

I'll give more feedback when mine arrive... Excited!

UPDATE 1: DOH! The no-load current is like 290ma @12v!!!! WTF!? Gets toasty just doing nothing. Not so impressed any more. Also at 1.8A output I measured 1A/12.5V in = only 72% efficient. 

UPDATE 2:  Ok so the specs do mention the high quiescent current if you look closely, and if you can live with that the modules work very well; the load regulation is excellent.  It turns out the module does happily output well over 20A (tested at 30A - active cooling a good idea, the small heatsink gets literally hot enough to boil water; thermal cutoff is at about 120C(!) ) - however - the board the module is mounted on has a P-FET for reverse voltage protection on the input and that blows up (quite spectacularly; lets the magic smoke out) above about 15A input current. If you don't care about the protection you can bypass the fet with some (very) thick wire from the input terminals to the module and it works well at very high currents.

Overall it's a pretty good module as long as you're ok with max 13.8v input and wasting a fair bit of power as heat...






Tuesday, October 8, 2013

Wireless router dropping connection under load - dmesg shows "ath: phy0: Failed to stop TX DMA, queues=0x004!"

Symptom:
Atheros-chipset based router, specifically:
Router Model
Buffalo WZR-HP-G300NH
Firmware Version
DD-WRT v24-sp2 (05/27/13) std - build 21676
Kernel Version
Linux 3.9.4 #320 Mon May 27 02:09:45 CEST 2013 mips


Was dropping wireless connection to my Nexus 7 (and iPod touch) when downloading anything large, e.g. app updates.

Connection would drop on client, interrupting whatever was downloading, then few seconds later would reconnect and continue, then drop again, etc.

dmesg from shell on the router gave me:
ath: phy0: Failed to stop TX DMA, queues=0x004!

every time it dropped the connection. 

cat /sys/kernel/debug/ieee80211/phy0/ath9k/reset

    Baseband Hang: 2538
Baseband Watchdog:  0
   Fatal HW Error:  0
      TX HW error:  0
     TX Path Hang:  0
      PLL RX Hang:  0
        MCI Reset:  0

REALLY ANNOYING.  Lots of internet sleuthing later, I appear to have found a fix!


TL;DR - TRY THIS
Make sure you're not using WPA2/ TKIP mode! Use AES instead - do not use TKIP.

Simply switching from TKIP to AES made the problem disappear completely. 
SO happy about that.

Work for you? Comment below please :-)

Friday, February 8, 2013

Djangoh-my-goodness

Django is good, now I go kick the tires a bit...

Django-cms is absurdly good

Give this guy half an hour to explain why; he sold me. 

Swwwweeee-e-eee-eeet!

Tuesday, January 22, 2013

Sensor chip w/Active low pin 2 = *NUKE

Maxwell Technologies’ HSN-1000 radiation-hardened Hybrid Nuclear Event Detecto


Kyle : wtf do you use that chip for?
Kyle : bomb warning device?
Dr Tune: no it's to launch a retaliatory nuclear attack
Dr Tune: you hook the active low *NED output (via a fet) to the ignition system on yr ICBM
Dr Tune: optionally you could have a toggle switch or something
 Dr Tune: 4 safeness
Kyle : well at least it triggers on a detonation and not just spotting something in the air
Dr Tune: yeah I wonder how they do production testing
Dr Tune: chips prolly veh expensive
Dr Tune: anyway
Dr Tune: comedic, and I love it just has pin 2 as essentially *NUKE
Kyle : lol yeah
Dr Tune: maybe hook it up to a piezo buzzer or something, so if you don't notice that you've just been nuked, it'll let you know
Kyle : yeah i was thinking its probably part of some sensor network to notify the pentagon or something
Kyle : immediately adjust the defcon level
Kyle : or i guess its not defcon anymore
Dr Tune: ya someone in pentagon has haxored up an arduino
Kyle : go to purple alert or something
Dr Tune: well only what 5 defcons
Dr Tune: so can use an attiny


Tuesday, November 20, 2012

Snoop NFC RFID card with RTL-SDR dongle

It's been a big year for radio fun!
Playing with NFC / RFID tags recently it occurred to me that the RTL-SDR dongles could potentially be used to sniff 13.56Mhz tags.

As it happens the RTL tuner won't quite tune as low as 13Mhz, but.. the first harmonic at 26Mhz works great!

Here's a Mifare Classic 4K card being repeatedly read by an SCL3711 NFC reader. I wedged an antenna next to the reader, fired up SDR-Sharp and here we go...

SCL3711 reader + Mifare 4k + antenna to RTL dongle

Center signal = 13.56Mhz carrier from reader, side spurs = ASK modulated reply from card :-)

Next stop, demodulation and a nice cup of tea. 

Video:


Addendum - while video shows antenna strapped to the card, this setup seems to receive both card+reader signals just fine from 15 feet away!

Later:  Ok never mind the "15 foot" stuff - not true it seems. Because I was running RTL dongle + NFC on the same PC it was coupling the RF signals through the USB lines, making things look very much better than they really were. I tried tag reading with a non-USB-wired Nexus 7 and the antenna range (for the signal from the card) is as "near field" as you'd expect. So; handy and cheap but not ground-breaking :-)

Friday, April 13, 2012

Mongodb pros and cons - scalability, management in production

Here's a nice easy one...

Don't use mongodb, tune your SQL properly, fool!

I experimented with it a while ago and what I found almost exactly matched what this guy found.
Read what he says and believe.


I didn't go anywhere near production with Mongo, cos I found it basically didn't work very well and mysql (when given some attention) we find to be astonishingly reliable and speedy. (we do thousands of queries/sec/mysql box)

I don't normally hate on free sw, but kids are getting their fingers trapped in this one.

Wednesday, March 7, 2012

"Mysql server has gone away" or "Lost connection to mysql server" when using Amazon RDS for for backup or whatev's

Hey,
OMFG what a PITA.
You run long mysql jobs, especially on an amazon RDS instance, especially e.g. backup, and it randomly fails, esp as the db gets bigger, and esp after several hours.
Well FML!
The answer is all over Google; it's either

a) [most common] the "net_write_timeout" variable on the source server (e.g. that you're dumping from); the AWS default is like 60s, which is sensibly cautious if your clients are some crashy bullshit (as hanging result sets/cursors are obviously expensive to keep lying around). 60s is fine for a web app, but if your client is occasionally/randomly gets stalled for a really long time (think; EBS, Innodb reindex if you're streaming direct via a pipe from mysqldump | mysql to do server->server backups; which can be a fine idea depending on yr needs).

OR

b) [less common] the destination server that you're unpacking/writing to has timed out for similar reasons; you were in the middle of providing [usually a metric fuck-ton] of data in an INSERT or UPDATE and the server doing the insert got hung up on something randomly once in a blue moon (e.g. system backup) and boom; the mysql box you're writing too tells you to f-off.
Typical AWS timeout here (net_read_timeout) is like 30s.

Ok so there you go; AWS defaults are sensible for a high-volume web db trying to protect itself from bad clients. Backups occasionally classify as 'bad clients'. FML again.

------THE FIX:

--EITHER (easy,global)
a) Change your RDS instance settings (amazon control panel) to set 'net_read_timeout" (and write) to something bigger globally across all connections. You might pick e.g. 20mins. If you have a lot of crappy/dropping DB connections tbis might be an issue.
--OR-- (usually easy for client code, not for mysqldump)
b) If you're running client sql code (e.g. php,python) simply do "SET net_write_timeout=3600"or whatever (or read_timeout, depending if yr problem is in SELECT or INSERT/UPDATEs) on each conn after you open it and bingo.
The var is set per-connection. This works perfectly for client code but not for mysqldump backups which I'll get to below.
--OR-- (middling, fixes mysqldump)
If your problem is with mysqldump piped dumps vi
e.g.
mysqldump yadda | ... | mysql yadda
(I do this using 'tee' and pipe a copy via gzip into a backup file at the same time I copy a db direct from one host to another making a compressed copy @ same time with no limit on db size. ..actually that is why I'm writing this..)

The issue you see is when the target DB stalls (can happen for e.g 1-10 min at bad times) the source DB times out (quickly; 60s default) on the write socket. This is not AFAIK fixable with normal mysqldump without changing the server's global timeouts for everyone.

The obvious fix is for mysqldump to send "set net_write_timeout=blah" after opening the conn it uses for dumping. Wierdly I cannot make it do that regardless of options, so I hit up the src code.

Basically I patched mysqldump so it sends "net_write_timeout=somebigtime" to the source server AND prefixes "set net_read_timeout=blah" into the SQL dump it outputs.

This solves both ends of the problem, especially when piping from one server to another with msqldump | mysql - both source and dest servers set the timeout _temporarily on that connection_ to a nice long value, e.g. 1hr.


Fixing mysqldump so it sends "net_write_timeout"

So I basically grabbed the mysql src and compiled it (google), on an aws box.
(actually "yum install mysql-devel ncurses-devel" may be handy, prolly a few more)
You don't need all the mysql stuff, just mysqldump,
..but I compiled everything (./configure {google for opts} and make)

MySqldump is in client/ and all the guts is in mysqldump.c
The hack is utterly trivial;

at the end of "connect_to_db" before teh DBUG_RETURN I added


#ifdef MUNKY_HACK
my_snprintf(buff, sizeof(buff), "SET net_write_timeout=3600");
if (mysql_query_with_error_report(mysql, 0, buff))
DBUG_RETURN(1);
#endif


..which is most important and tells the src server to use longer timeouts just for the dumping.

IF you're being fancy and piping from one db to another, you may want the output dump to include a prefix telling the target db to use longer timeouts.
I addeed this to near the top of 'dump_table' as ;

fprintf(md_result_file, "/* Munky Hack*/\n set net_read_timeout=3600;\n");


It's that easy (it seems) to make this stuff work properly reliably

Monday, January 23, 2012

Tedious issues escaping/quoting strings for MySQL? Use hex! It's awesome!

Hiya,
Ok sure yes you 'escape' all your strings for SQL (i.e. replace `'` with \' and so on for other nonprintable).
Sometimes this is unsuitable.

Did you know you can avoid all that palarva and just pass your strings as hex?

Check it out!

For a varchar (or blob, or whatev) column, just try instead of

insert col='blah' into mytable
=
insert col=0x626c6168 into mytable

How awesome is that? Who knew?

Also, btw, you can get mysqldump to also output blobs as hex, which makes for easier parsing - see the help output

Wednesday, January 18, 2012

See wikipedia during january 18th blackout

Yes, yes wikipedia, we know you're all radical and cool.
Anyway, just append

?banner=none

to the end of your URL, for example;


kthxbye

Friday, January 6, 2012

Obscure packetization bug in Verizon cellular HTTP proxy 'Harmony'! Does your app fail on VZW cell but work on wifi?

Wow this is a fucking bug and a half;

(On iPhone, but applies to everything)
Verizon currently appears to proxy any HTTP request over any port regardless of whether you asked for it. It adds

"X-Via: Harmony proxy"

to show how much it 'helped'. Thanks, if I wanted a proxy I'd ask for one.

It does it even on non-port 80!! FFS!
It appears that anything that says HTTP/1.1 after opening a socket on any port is fair game for fuckwittery.

And, wonderfully, Harmony Proxy has a packet reassembly bug!

The client app was (inadvertently) writing the HTTP request split into two TCP packets;
The first packet was only 22 bytes long, containing the URL
The second packet was 500 or so bytes and was the rest of the header continuing from " HTTP/1.1\r\n...etc"

Hence the very first line of the HTTP req was split into two TCP packets. This is obviously rather unusual.
The proxy freaks out at this, throws away all the HTTP headers, and just generally screws the request up (although it does send it)..

So, when using socket .send() , make sure you've buffered at least the first few lines of your headers in one go.

if your stuff works over wifi, other cell networks, but not VZW, and you're using HTTP...
watch out for this. It's a bug in their proxy.

Tuesday, November 9, 2010

Rewriting (proxying) a TCP stream in one line

Damn unix is great...

Step 1: In a shell, set up netcat to listen on TCP 5500:
nc -l -p 5500

Step 2: In another shell/on an intermediate machine..
nc -l -p 50000 -c 'sed -u -e s/billy/freddy/g | nc localhost 5500'

Step 3: In a third shell,
nc localhost 50000

..and start typing stuff, including the word "billy"

Ok so the third shell will talk to the first shell and replace "billy" with "freddy".
Note this is bidirectional - type in first shell and it goes back to third one (without rewrite)

How handy is that? VERY!

If you need a TCP stream (e.g. gnu debugger) intercepted and rewritten slightly.. that's yer man.

Thank you beardy unix gods from 1972!