2018-05-24 14:04:55    185    1    0
## Emoji `:cn:` `:smile:` `:100:` `:v:` You can find more Emoji from [https://afeld.github.io/emoji-css/](https://afeld.github.io/emoji-css/) ## Block-level Custom Containers ::: success :tada:
2017-12-24 07:23:20    262    0    0

Use unexported variables

The unexported variables

unexport/i.go

  1. package unexport
  2. var i int
  3. func init() {
  4. i = 2
  5. }

The new variables points the unexported variables

main.go

  1. package main
  2. import (
  3. "fmt"
  4. _ "unsafe"
  5. _ "unexport"
  6. )
  7. //go:linkname I unexport.i
  8. var I int
  9. func main() {
  10. fmt.Println(I)
  11. }

Use unexported functions

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/alangpierce/go-forceexport"
  5. )
  6. func main() {
  7. var timeNow func() (int64, int32)
  8. err := forceexport.GetFunc(&timeNow, "time.now")
  9. if err != nil {
  10. // Handle errors if you care about name possibly being invalid.
  11. fmt.Println(err)
  12. }
  13. // Calls the actual time.now function.
  14. sec, nsec := timeNow()
  15. fmt.Printf("%v %v", sec, nsec)
  16. }
2017-12-02 14:39:35    110    0    0

Tcpdump advanced filters

Original publication: 2007-10-01

Last update: 2016-02-14

Repost from https://blog.wains.be/2007/2007-10-01-tcpdump-advanced-filters/

Introduction

In this article, I will explain how to use tcpdump to:

  • know if IP options are set
  • find DF packets (packets which we don't want to be fragmented)
  • find fragmented packets
  • find datagrams with low TTL
  • find particular TCP flag combinations
  • find datagrams with particular data (here, packets with command MAIL from the SMTP protocol and GET command from HTTP)

Notes

I usually type tcpdump -n -i eth1 -s 1600 before my filter but I won't do that throughout the article. -n prevents DNS lookups, -i specifies the interface and -s specifies the size of the packets (default is 65536 bytes). Be careful if you use -s 0 because depending on the version, you might be capturing 64K or full-lenght packets.

All commands are typed as root.

Feel free to contact me f

2016-11-09 01:16:01    42    0    0

Introduction

Using a firewall is as much about making intelligent policy decisions as it is about learning the syntax. Firewalls like iptables are capable of enforcing policies by interpreting rules set by the administrator. However, as an administrator, you need to know what types of rules make sense for your infrastructure.

While other guides focus on the commands needed to get up and running, in this guide, we will discuss some of the decisions you will have to make when implementing a firewall. These choices will affect how your firewall behaves, how locked down your server is, and how it will respond to various conditions that are likely to occur from time to time. We will be using iptables as an example to discuss specifics, but most of the actual decisions will be relevant regardless of the tools used.

Deciding on a Default Policy

When constructing a firewall, one of the fundamental decisions that you must make

2016-11-09 01:03:33    31    0    0

Introduction

Iptables is a firewall that plays an essential role in network security for most Linux systems. While many iptables tutorials will teach you how to create firewall rules to secure your server, this one will focus on a different aspect of firewall management: listing and deleting rules.

In this tutorial, we will cover how to do the following iptables tasks:

  • List rules
  • Clear Packet and Byte Counters
  • Delete rules
  • Flush chains (delete all rules in a chain)
  • Flush all chains and tables, delete all chains, and accept all traffic

Note: When working with firewalls, take care not to lock yourself out of your own server by blocking SSH traffic (port 22, by default). If you lose access due to your firewall settings, you may need to connect to it via the console to fix your access. Once you are connected via the console, you can change your firewall rules to allow SSH access (or allow all traffic). If your saved fir

2016-11-09 01:03:32    35    0    0

Introduction

Iptables is the software firewall that is included with most Linux distributions by default. This cheat sheet-style guide provides a quick reference to iptables commands that will create firewall rules are useful in common, everyday scenarios. This includes iptables examples of allowing and blocking various services by port, network interface, and source IP address.

How To Use This Guide

  • If you are just getting started with configuring your iptables firewall, check out our introduction to iptables
  • Most of the rules that are described here assume that your iptables is set to DROP incoming traffic, through the default input policy, and you want to selectively allow traffic in
  • Use whichever subsequent sections are applicable to what you are trying to achieve. Most sections are not predicated on any other, so you can use the examples below independently
  • Use the Contents menu on the right side of this page (at
2016-10-20 02:46:08    71    0    0

Reason Why

Ever get the dreaded error:

  1. Virtual memory exhausted: Cannot allocate memory

With the first iterations of Raspberry Pi the Model A comes with 256mb of memory. While the Raspberry Pi B comes with a modest 512mb of memory. For most applications this amount of memory is actually quiet a bit. As soon as you start compiling your own binaries this amount starts to seem dismal.

Insert reason why swap on flash-based memory is bad here.

Limitations

The Raspbian distribution comes with a 100mb swapfile. This is actually a bit on the small side. A general rule of thumb is swapfile size should be about twice as much as the available RAM on the machine. In the examples below I have a Raspberry Pi B+. So the amount of swap I use is 1024mb.

Commands

We will change the configuration in the file /etc/dphys-swapfile :

  1. sudo nano /etc/dphys-swapfile

The default value in Raspbian is:

  1. CONF_SWAPSIZE=100

We will

2016-10-20 02:46:01    146    0    0

Principle


Using Docker on Raspberry Pi provides many different benefits (most explained here in French). However when developing new containers, it may require much more CPU and RAM power to build them or even to compile the binaries in armhf format. So this blog post describes how to create an ARM v7 image based on QEMU emulating an ARM Cortex-15 chip with 2Gb of RAM running Debian 8 Jessie.

Why Debian 8 Jessie ?

Simply because the embedded kernel is preconfigured for Docker (see the required modules there). I'll probably use HypriotOS in the future but for now that's good enough and i use the Docker packages directly built by Hypriot anyway.

Why not emulating the Raspberry Pi ?

Simply because the performances are really really bad and it is limited to 256Mb of RAM. I tried multiple times but it is really too slow so i preferred to switch to a different emulator but keeping the same CPU architecture.

Why only a Cort

2016-10-20 02:41:28    52    0    0

Commit some changes

  1. # ...
  2. git commit -am "0" # got hash hash0
  3. # ...
  4. git commit -am "1" # got hash hash1
  5. # ...
  6. git commit -am "2" # got hash hash2
  7. # ...
  8. git commit -am "3" # got hash hash3

Revert change 1, 2, and 3

  1. git reset --hard hash0
  2. git reset --soft hash3
  3. git commit -am 'Reverted 1 2 3'
git    2016-10-20 02:41:23    51    0    0

0. Add a submodule

  1. git submodule add [-b <branch>]<repository> [<path>]
  2. git submodule init
  3. git submodule update

1. Remove config entries:

  1. git config -f .git/config --remove-section submodule.$submodulepath
  2. git config -f .gitmodules --remove-section submodule.$submodulepath

2. Remove directory from index:

  1. git rm --cached $submodulepath

3. Commit

4. Delete unused files:

  1. rm -rf $submodulepath
  2. rm -rf .git/modules/$submodulepath

Background

When you do git submodule add, it only adds it to .gitmodules, but once you did git submodule init, it added to .git/config.

So if you wish to remove the modules, but be able to restore it quickly, then do just this:

  1. git rm --cached $submodulepath
  2. git config -f .git/config --remove-section submodule.$submodulepath

It is a good idea to do git rebase HEAD first and git commit at the end, if you put this in a script.