Sunday, April 19, 2015

Remote Debugging and Installing to Android Emulator

Running an Android Emulator in my development laptop definitely slowing all the system.
I switched to vim instead of painful Android Studio IDE. My Laptop still slow.
So i came up with a solution that i could use my other laptop to run the android emulator.
The emulator now runs, with 5554:MyAvd-1 at the title.

Port forwarding in linux using ssh is really simple. I run
$ ssh adesanto@ -L 5555:
$ killall adb; adb devices

The result is no device attached. Strange, i googled and end with

I tried one of the answer from Christopher Orr,
  • ssh -NL 5556:localhost:5554 -L 5557:localhost:5555 myuser@remote-server
  • killall adb; adb devices
The result shows that there is a device at emulator-5556 but the status is offline.
After scroll down the answers i see that hheimbuerger, he forward mylaptop:5554 to target:5554
and  mylaptop:5555 to target:5555.

Aha! now after modify the tunnel and restart the adb process by
$ ssh -NL 5556:localhost:5554 -L 5557:localhost:5555 myuser@remote-server
$ killall adb; adb devices
I have my emulator list showing
List of devices attached
emulator-5554 device

Nice! i tried to run
$ adb logcat
It throws alot of messages at my screen showing it works!
Then i tried to upload one of my debug .apk, it uploads and running like charm.

Happy codding.

Saturday, April 18, 2015

Fedora/Centos Logging the iptables to /var/log/iptables.log

Recently my VPS got hacked and had to learn iptables to drop all outgoing traffic.
Everything seems to work, yeah google is your friend. But there was a problem.
In my fedora the iptables dropped packets logging did not appears to /var/log/messages
nor to /var/log/iptables.log.. strange.

Okay i started to dig why the log was not showed out. I know i am using rsyslog,
so i came out with this setting,

1. Create a file
    # touch /etc/rsyslog.d/iptables.conf
    # touch /var/log/iptables.log
2. Insert this into the config file
    :msg, startswith, "iptables:" /var/log/iptables.log
  & ~ Well this rules is not working, since the rsyslog format is to add timestamp
    at every beginning line of log. So modified it slightly with "contains" keyword.
   :msg, contains, "iptables:" /var/log/iptables.log
  & ~
3. restart the service
    # service  rsyslog restart

Now i can see all the log of dropped packets at /var/log/iptables.log

GNU/Linux  rocks!