This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# OpenVPN Server | |
iptables -t nat -I POSTROUTING 1 -s 10.8.0.0/24 -o eth0 -j MASQUERADE | |
iptables -I INPUT 1 -i tun0 -j ACCEPT | |
iptables -I FORWARD 1 -i eth0 -o tun0 -j ACCEPT | |
iptables -I FORWARD 1 -i tun0 -o eth0 -j ACCEPT | |
iptables -I INPUT 1 -i eth0 -p udp --dport 1194 -j ACCEPT | |
iptables -I OUTPUT 1 -o eth0 -p udp --sport 1194 -j ACCEPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"time" | |
) | |
type someType struct { | |
Time *time.Time `json:"time"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set a timeout of 10secs if no timeout in the underlying | |
// http client and no timeout set in the context. | |
_, ok := ctx.Deadline() | |
if c.c.Timeout == 0 && !ok { | |
var cancel context.CancelFunc | |
ctx, cancel = context.WithTimeout(ctx, time.Second*10) | |
defer cancel() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello World") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type logger struct { | |
s string | |
s2 string | |
} | |
func (l *logger) do(in string) { | |
log.Println(in) | |
} | |
type checker struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type loggerAndChecker struct { | |
*logger | |
*checker | |
s string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type doerAndValidator interface { | |
doer | |
validator | |
doSomething(string) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type logger struct{} | |
func (l *logger) do(in string) { | |
if l.validate(in) { | |
log.Println(in) | |
} | |
} | |
func (l *logger) validate(in string) bool { | |
if len(in) == 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type logger struct{} | |
func (l *logger) do(in string) { | |
if l.validate(in) { | |
log.Println(in) | |
} | |
} | |
func (l *logger) validate(in string) bool { | |
if len(in) == 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type loggerAndChecker struct { | |
l *logger | |
c *checker | |
} | |
func main() { | |
var lc loggerAndChecker | |
in := "Hello World" | |
if lc.c.validate(in) { | |
lc.l.do(in) |
NewerOlder