Code Blog

Displaying 6-10 of 46 results.
2017/03/31 MacOSX

I had a problem when starting a new terminal window (running bash shell) that the hostname displayed was wrong, and was actually instead showing different network connected hostnames. To fix this, first check if hostname is set on the local machine, to do this type the following in the terminal:

scutil --get HostName

If there's no hostname set for the local machine, then is can be defined with this command:

sudo scutil --set HostName 'computerHostName'

After restarting the terminal window the hostname was showing correctly in my case. Another way to fix this is to just change the prompt for the shell (edit the ~/.bash_profile if running bash), but I think this is a better way to resolve it. It is a bit confusing with hostname / computer name / local hostname as they are used in different parts of Mac OS for bonjour and sharing. In this case it seems as I didn't have a hostname defined, the system instead got another hostname from the DNS server.

 

2017/02/10 MacOSX

A quite common scenario: An update of Mac OS X breaks some driver, usually it is the printer driver, but this time it was the USB-to-Ethernet device that stopped working (a Macally U3HUBGB). I checked for driver updates but Macally latest driver is for MacOS 10.9, however it uses a Axis chip (AX88179) and the latest driver can be downloaded directly from the suppliers website:

http://www.asix.com.tw/download.php?sub=driverdetail&PItemID=131

My problem was that Network settings showed the "cable unplugged" status. I reinstalled and rebooted multiple times but could still not get it to run.

I tried to remove the AX88179 device from the "Network settings" and then reinstall the driver. Now it didn't show up at all! After removing the NetworkInterfaces.plist I managed to get it back again, but this still didn't solve the "cable unplugged" error. 

sudo rm /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist

In the end I manually removed the kext (sudo rm -rf /Library/Extensions/AX88179_178A.kext), rebooted, reinstalled the latest driver and finally rebooted again. After that it started working again (the network LEDs on the USB hub lit up directly on reboot). I am running MacOS Sierra (10.12.3) at the moment.

Debugging information:

  • Terminal command: kextstat | grep asix
  • "About This Mac" -> "System Report ..." -> "Software" -> "Extensions"
  • "About This Mac" -> "System Report ..." -> "Hardware" -> "USB"

 

2016/12/14 VPN,OpenWRT

I made a previous post about how I set up Shadowsocks on my OpenWRT router (back in February, see post ...). My router had basically stopped working so I had to go through it and try to understand what was wrong. After some testing it seemed that the TCP-tunnel was working fine but the ChinaDNS had problems working correctly.

The shadowsocks-libev has also been updated. The shadowsocks-libev-spec seems to have been discontinued and is now merged in the shadowsocks-libev, which has more functions sorted (now supporting SOCKS proxy and transparent proxy). The same is true for the luci frontend, everything is now through one single GUI.

To solve the problems with DNS I also installed the DNS-forwarder package.

Shadowsocks-libev is written in pure C and only depends on libev and OpenSSL or mbedTLS or PolarSSL.
Using alternative crypto library There are three crypto libraries available: OpenSSL (default) mbedTLS PolarSSL (Deprecated)

shadowsocks-libev
Client side/
└── usr/
  └── bin/
    ├── ss-local // provides SOCKS proxy
    ├── ss-redir // provides transparent proxy, since v2.2.0 also supports UDP
    └── ss-tunnel // used for packet transmission, can be used DNS lookups

shadowsocks-libev-server
Server side/
└── usr/
  └── bin/
    └── ss-server // server executable

wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ { printf("%s/%d\n"
, $4, 32-log($5)/log(2)) }' > ignore.list

I installed the following packages by first downloading them on my computer and scp them over to the router.

opkg update

opkg install ip ipset libopenssl iptables-mod-tproxy

Shadowsocks-libev required that I first installed libpcre and libpthread packages.

ChinaDNS_1.3.2-4_ar71xx.ipk

dns-forwarder_1.1.1-1_ar71xx.ipk
libpcre_8.39-1_ar71xx.ipk
libpthread_0.9.33.2-1_ar71xx.ipk
luci-app-chinadns_1.5.0-1_all.ipk
luci-app-shadowsocks_1.3.7-1_all.ipk
shadowsocks-libev_2.5.6-1_ar71xx.ipk

/etc/config/dns-forwarder

config dns-forwarder
option enable '1'
option listen_addr '0.0.0.0'
option listen_port '5300'
option dns_servers '8.8.8.8'

/etc/config/dhcp

config dnsmasq
option domainneeded '1'
option boguspriv '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option expandhosts '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option localservice '1'
option noresolv '1'
option nohosts '1'
option local '127.0.0.1#5353'

config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv6 'server'
option ra 'server'
option ra_management '1'

config dhcp 'wan'
option interface 'wan'
option ignore '1'

config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'


/etc/config/chinadns

config chinadns
option enable '1'
option bidirectional '0'
option chnroute '/etc/chinadns_chnroute.txt'
option port '5353'
option server '114.114.114.114,127.0.0.1#5300'

Another new feature is that Shadowsocks now supprts AES-256-CTR. I have used CFB before. CTR is used if you want good parallelization (ie. speed), instead of CBC/OFB/CFB.

Links:

https://github.com/shadowsocks/shadowsocks-libev

 

2016/11/23 MacOSX

On Mac OS X / Unix start a terminal window and run the following commands:

Modified timedate

touch -mt YYYYMMDDhhmm filepath
touch -mt 201611231200 *

The example above will update all files in the current folder with modified datetime of 2016/11/23 12.00AM. This helped me solve some file upload sorting order problem in the past.

Create and modified timedate

Dropping the "-m" flag will update both created and modified datetime

touch -t 201611231200 *

 

2016/11/22 MacOSX

I had some problems getting a Fuji-Xerox DocuPrint to print from my Mac, I tried multiple drivers but it still only printed garbage (see photo below). Turns out that the Mac requires the printer to support postscript. It's a bit confusing as this printer (FX DocuPrint 2065) says it supports Mac and it also gets autodetected when I try to add the printer. Problem is, the printer I tried to add doesn't have the postscript module (it's actually an optional addon!) so in order to get it to print correctly I need to install a non-ps printer driver! This is quite tricky to find out, and also not so easy to find where to download this driver. 

Links for downloading the non-ps driver at http://macintoshhowto.com/printing/printing-to-a-non-postscript-fuji-xerox-printer.html 

Printer output using postscript driver when printer doesn't support postscript! 

Note that the autodetected driver says "PS", but if the printer doesn't have the postscript module this will not work.

Need to click "View All" to show the download link for the "Non PS" driver.

After installing the downloaded "Non PS" driver, you need to manually select it when adding the printer.