SlideShare uma empresa Scribd logo
1 de 203
Baixar para ler offline
go
for the paranoid network programmer
@feyeleanor
1go for the paranoid network programmer slideshare.net/feyeleanor
twitter://@feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor
high voltage
networking
concurrency
cryptography
go for the paranoid network programmer slideshare.net/feyeleanor
http
4go for the paranoid network programmer slideshare.net/feyeleanor
package main
import (
. "fmt"
"net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
http.HandleFunc("/hello", Hello)
if e := http.ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor5
package main
import (
. "fmt"
"net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
http.HandleFunc("/hello", Hello)
if e := http.ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor6
package main
import (
. "fmt"
. "net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor7
package main
import (
. "fmt"
. ”net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor8
package main
import (
. "fmt"
. ”net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor9
package main
import (
. "fmt"
. ”net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor10
package main
import (
. "fmt"
. ”net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor11
package main
import (
. "fmt"
. ”net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", Hello)
if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}
func Hello(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
}
go for the paranoid network programmer slideshare.net/feyeleanor12
package main
import (
. "fmt"
. "net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
})
ListenAndServe(ADDRESS, nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor13
package main
import (
. "fmt"
. "net/http"
)
const MESSAGE = "hello world"
const ADDRESS = ":1024"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE)
})
ListenAndServe(ADDRESS, nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor14
https
15go for the paranoid network programmer slideshare.net/feyeleanor
package main
import (
. "fmt"
. "net/http"
)
const ADDRESS = ":1025"
func main() {
message := "hello world"
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, message)
})
ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor16
package main
import (
. "fmt"
. "net/http"
)
const ADDRESS = ":1025"
func main() {
message := "hello world"
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, message)
})
ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor17
package main
import (
. "fmt"
. "net/http"
)
const ADDRESS = ":1025"
func main() {
message := "hello world"
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, message)
})
ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor18
package main
import (
. "fmt"
. "net/http"
)
const ADDRESS = ":1025"
func main() {
message := "hello world"
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, message)
})
ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil)
}
go for the paranoid network programmer slideshare.net/feyeleanor19
multiple http servers
20go for the paranoid network programmer slideshare.net/feyeleanor
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor21
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor22
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor23
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor24
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor25
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor26
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor27
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor28
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
done := make(chan bool)
go func() {
ListenAndServe(":1024", nil)
done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor29
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
Spawn(
func() {
ListenAndServe(":1024", nil)
},
func() {
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
},
)
}
go for the paranoid network programmer slideshare.net/feyeleanor30
package main
import . "fmt"
import . "net/http"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
Spawn(func() {
ListenAndServe(":1024", nil)
})
Spawn(func() {
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
})
}
go for the paranoid network programmer slideshare.net/feyeleanor31
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for l := len(f); l > 0; l-- {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor32
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for l := len(f); l > 0; l-- {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor33
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for l := len(f); l > 0; l-- {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor34
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for _, _ = range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor35
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor36
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor37
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor38
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor39
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor40
package main
func Spawn(f ...func()) {
done := make(chan bool)
for _, s := range f {
go func(server func()) {
server()
done <- true
}(s)
}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor41
waitgroups
42go for the paranoid network programmer slideshare.net/feyeleanor
package main
import . "net/http"
import "sync"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {})
var servers sync.WaitGroup
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServe(":1024", nil)
}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor43
package main
import . "net/http"
import "sync"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {})
var servers sync.WaitGroup
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServe(":1024", nil)
}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor44
package main
import . "net/http"
import "sync"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {})
var servers sync.WaitGroup
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServe(":1024", nil)
}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor45
package main
import . "net/http"
import "sync"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {})
var servers sync.WaitGroup
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServe(":1024", nil)
}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor46
package main
import . "net/http"
import "sync"
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {})
var servers sync.WaitGroup
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServe(":1024", nil)
}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor47
package main
import (
. "fmt"
. "net/http"
"sync"
)
var servers sync.WaitGroup
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
Spawn(func() { ListenAndServe(":1024", nil) })
Spawn(func() {
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
})
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor48
package main
import (
. "fmt"
. "net/http"
"sync"
)
var servers sync.WaitGroup
func main() {
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain")
Fprintf(w, "hello world")
})
Spawn(func() { ListenAndServe(":1024", nil) })
Spawn(func() {
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
})
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor49
package main
func Spawn(f ...func()) {
for _, s := range f {
servers.Add(1)
go func(server func()) {
defer servers.Done()
server()
}(s)
}
}
go for the paranoid network programmer slideshare.net/feyeleanor50
package main
func Spawn(f ...func()) {
for _, s := range f {
servers.Add(1)
go func(server func()) {
defer servers.Done()
server()
}(s)
}
}
go for the paranoid network programmer slideshare.net/feyeleanor51
tcp server
52go for the paranoid network programmer slideshare.net/feyeleanor
package main
import . "fmt"
import "net"
func main() {
if listener, e := net.Listen("tcp", ":1024"); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor53
package main
import . "fmt"
import "net"
func main() {
if listener, e := net.Listen("tcp", ":1024"); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor54
package main
import . "fmt"
import "net"
func main() {
if listener, e := net.Listen("tcp", ":1024"); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor55
package main
import . "fmt"
import "net"
func main() {
if listener, e := net.Listen("tcp", ":1024"); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor56
package main
import . "fmt"
import "net"
func main() {
if listener, e := net.Listen("tcp", ":1024"); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor57
package main
import . "fmt"
import "net"
func main() {
Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
})
}
func Listen(p, a string, f func(net.Conn)) (e error) {
var listener net.Listener
if listener, e = net.Listen(p, a); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go f(connection)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor58
package main
import . "fmt"
import "net"
func main() {
Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
})
}
func Listen(p, a string, f func(net.Conn)) (e error) {
var listener net.Listener
if listener, e = net.Listen(p, a); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go f(connection)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor59
package main
import . "fmt"
import "net"
func main() {
Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
})
}
func Listen(p, a string, f func(net.Conn)) (e error) {
var listener net.Listener
if listener, e = net.Listen(p, a); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go f(connection)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor60
package main
import . "fmt"
import "net"
func main() {
Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close()
Fprintln(c, "hello world")
})
}
func Listen(p, a string, f func(net.Conn)) (e error) {
var listener net.Listener
if listener, e = net.Listen(p, a); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go f(connection)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor61
tcp client
62go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor63
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor64
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor65
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor66
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor67
package main
import "bufio"
import . "fmt"
import "net"
func main() {
if c, e := net.Dial("tcp", ":1024"); e == nil {
defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor68
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func Dial(p, a string, f func(net.Conn)) (e error) {
var c net.Conn
if c, e = net.Dial(p, a); e == nil {
defer c.Close()
f(c)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor69
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func Dial(p, a string, f func(net.Conn)) (e error) {
var c net.Conn
if c, e = net.Dial(p, a); e == nil {
defer c.Close()
f(c)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor70
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func Dial(p, a string, f func(net.Conn)) (e error) {
var c net.Conn
if c, e = net.Dial(p, a); e == nil {
defer c.Close()
f(c)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor71
tcp/tls server
72go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor73
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor74
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor75
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor76
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor77
package main
import "crypto/rand"
import "crypto/tls"
import . "fmt"
func main() {
Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world")
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
Rand: rand.Reader,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor78
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor79
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor80
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor81
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor82
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor83
package main
import "crypto/tls"
func Listen(a string, conf *tls.Config, f func(*tls.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c *tls.Conn) {
defer c.Close()
f(c)
}(connection.(*tls.Conn))
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor84
package main
import "crypto/tls"
import "net"
func Listen(a string, conf *tls.Config, f func(net.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
f(c)
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor85
package main
import "crypto/tls"
import "net"
func Listen(a string, conf *tls.Config, f func(net.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if connection, e := listener.Accept(); e == nil {
go func(c net.Conn) {
defer c.Close()
f(c)
}(connection)
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor86
package main
import "crypto/tls"
import "net"
func Listen(a string, conf *tls.Config, f func(net.Conn)) {
if listener, e := tls.Listen("tcp", a, conf); e == nil {
for {
if c, e := listener.Accept(); e == nil {
go Handle(c, f)
}
}
}
}
func Handle(c net.Conn, f func(net.Conn)) {
defer c.Close()
f(c)
}
go for the paranoid network programmer slideshare.net/feyeleanor87
tcp/tls client
88go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor89
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor90
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor91
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor92
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor93
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func ConfigTLS(c, k string) (r *tls.Config) {
if cert, e := tls.LoadX509KeyPair(c, k); e == nil {
r = &tls.Config{
Certificates: []tls.Certificate{ cert },
InsecureSkipVerify: true,
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor94
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func Dial(a string, conf *tls.Config, f func(net.Conn)) {
if c, e := tls.Dial("tcp", a, conf); e == nil {
defer c.Close()
f(c)
}
}
go for the paranoid network programmer slideshare.net/feyeleanor95
package main
import "bufio"
import "crypto/tls"
import . "fmt"
import "net"
func main() {
Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil {
Printf(m)
}
})
}
func Dial(a string, conf *tls.Config, f func(net.Conn)) {
if c, e := tls.Dial("tcp", a, conf); e == nil {
defer c.Close()
f(c)
}
}
go for the paranoid network programmer slideshare.net/feyeleanor96
udp serve
97go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor98
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor99
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor100
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor101
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor102
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor103
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor104
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor105
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor106
package main
import "net"
func main() {
HELLO_WORLD := []byte("Hello Worldn")
Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a)
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil {
go f(conn, client, b[:n])
}
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor107
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor108
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor109
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor110
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor111
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor112
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor113
package main
import "net"
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.ListenUDP("udp", address); e == nil {
ServeUDP(conn, func(c *net.UDPAddr, b []byte) {
f(conn, c, b)
})
}
}
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil {
go f(client, b[:n])
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor114
udp request
115go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor116
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor117
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor118
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor119
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor120
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor121
package main
import "bufio"
import . "fmt"
import "net"
func main() {
Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil {
if m, e := bufio.NewReader(conn).ReadString('n'); e == nil {
Printf("%v", m)
}
}
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor122
aes encrypt
123go for the paranoid network programmer slideshare.net/feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor124
package main
import "net"
const AES_KEY = "0123456789012345"
func main() {
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil {
c.WriteToUDP(m, a)
}
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
// see udp serve
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
// see udp serve
}
go for the paranoid network programmer slideshare.net/feyeleanor125
package main
import "net"
const AES_KEY = "0123456789012345"
func main() {
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil {
c.WriteToUDP(m, a)
}
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
// see udp serve
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
// see udp serve
}
go for the paranoid network programmer slideshare.net/feyeleanor126
package main
import "net"
const AES_KEY = "0123456789012345"
func main() {
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil {
c.WriteToUDP(m, a)
}
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
// see udp serve
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
// see udp serve
}
go for the paranoid network programmer slideshare.net/feyeleanor127
package main
import "net"
const AES_KEY = "0123456789012345"
func main() {
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil {
c.WriteToUDP(m, a)
}
})
}
func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) {
// see udp serve
}
func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) {
// see udp serve
}
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor128
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor129
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor130
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor131
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor132
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor133
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor134
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor135
package main
import "crypto/aes"
import "crypto/cipher"
func Encrypt(m, k string) (o []byte, e error) {
if o, e = PaddedBuffer([]byte(m)); e == nil {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
o = CryptBlocks(o, b)
}
}
return
}
func PaddedBuffer(m []byte) (b []byte, e error) {
b = append(b, m...)
if p := len(b) % aes.BlockSize; p != 0 {
p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!!
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor136
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor137
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor138
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor139
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor140
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor141
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor142
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor143
package main
import "crypto/aes"
import "crypto/cipher"
func CryptBlocks(b []byte, c cipher.Block) (o []byte) {
o = make([]byte, aes.BlockSize + len(b))
copy(o, IV())
enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize])
enc.CryptBlocks(o[aes.BlockSize:], b)
return
}
func IV() (b []byte) {
b = make([]byte, aes.BlockSize)
if _, e := rand.Read(b); e != nil {
panic(e)
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor144
aes decrypt
145go for the paranoid network programmer slideshare.net/feyeleanor
package main
import . "fmt"
import "net"
const AES_KEY = "0123456789012345"
func main() {
Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil {
Printf("%sn", m)
}
})
})
}
func Dial(a string, f func(net.Conn)) {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
f(conn)
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor146
package main
import . "fmt"
import "net"
const AES_KEY = "0123456789012345"
func main() {
Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil {
Printf("%sn", m)
}
})
})
}
func Dial(a string, f func(net.Conn)) {
// see udp request
}
go for the paranoid network programmer slideshare.net/feyeleanor147
package main
import . "fmt"
import "net"
const AES_KEY = "0123456789012345"
func main() {
Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil {
Printf("%sn", m)
}
})
})
}
func Dial(a string, f func(net.Conn)) {
// see udp request
}
go for the paranoid network programmer slideshare.net/feyeleanor148
package main
import . "fmt"
import "net"
const AES_KEY = "0123456789012345"
func main() {
Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil {
Printf("%sn", m)
}
})
})
}
func Dial(a string, f func(net.Conn)) {
// see udp request
}
go for the paranoid network programmer slideshare.net/feyeleanor149
package main
import "net"
func RequestMessage(conn net.Conn, f func([]byte)) (e error) {
if _, e = conn.Write([]byte("n")); e == nil {
m := make([]byte, 1024)
var n int
if n, e = conn.Read(m); e == nil {
f(m[:n])
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor150
package main
import "net"
func RequestMessage(conn net.Conn, f func([]byte)) (e error) {
if _, e = conn.Write([]byte("n")); e == nil {
m := make([]byte, 1024)
var n int
if n, e = conn.Read(m); e == nil {
f(m[:n])
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor151
package main
import "net"
func RequestMessage(conn net.Conn, f func([]byte)) (e error) {
if _, e = conn.Write([]byte("n")); e == nil {
m := make([]byte, 1024)
var n int
if n, e = conn.Read(m); e == nil {
f(m[:n])
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor152
package main
import "net"
func RequestMessage(conn net.Conn, f func([]byte)) (e error) {
if _, e = conn.Write([]byte("n")); e == nil {
m := make([]byte, 1024)
var n int
if n, e = conn.Read(m); e == nil {
f(m[:n])
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor153
package main
import "net"
func RequestMessage(conn net.Conn, f func([]byte)) (e error) {
if _, e = conn.Write([]byte("n")); e == nil {
m := make([]byte, 1024)
var n int
if n, e = conn.Read(m); e == nil {
f(m[:n])
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor154
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor155
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor156
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor157
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor158
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor159
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor160
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor161
package main
import "crypto/cipher"
import "crypto/aes"
func Decrypt(m []byte, k string) (r []byte, e error) {
var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil {
var iv []byte
iv, m = Unpack(m)
c := cipher.NewCBCDecrypter(b, iv)
r = make([]byte, len(m))
c.CryptBlocks(r, m)
}
return
}
func Unpack(m []byte) (iv, r []byte){
return m[:aes.BlockSize], m[aes.BlockSize:]
}
go for the paranoid network programmer slideshare.net/feyeleanor162
rsa encrypt
163go for the paranoid network programmer slideshare.net/feyeleanor
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor164
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor165
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor166
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor167
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor168
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor169
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor170
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor171
package main
import . "bytes"
import "crypto/rsa"
import "encoding/gob"
import "net"
func main() {
HELLO_WORLD := []byte("Hello World")
RSA_LABEL := []byte("served")
Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil {
if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil {
c.WriteToUDP(m, a)
}
}
return
})
}
go for the paranoid network programmer slideshare.net/feyeleanor172
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) {
return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor173
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) {
return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor174
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) {
return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor175
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) {
return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor176
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) {
return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor177
rsa decrypt
178go for the paranoid network programmer slideshare.net/feyeleanor
package main
import "crypto/rsa"
import . "fmt"
import "net"
func main() {
Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil {
if m, e := Decrypt(k, m, []byte("served")); e == nil {
Println(string(m))
}
}
})
}
go for the paranoid network programmer slideshare.net/feyeleanor179
package main
import "crypto/rsa"
import . "fmt"
import "net"
func main() {
Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil {
if m, e := Decrypt(k, m, []byte("served")); e == nil {
Println(string(m))
}
}
})
}
go for the paranoid network programmer slideshare.net/feyeleanor180
package main
import "crypto/rsa"
import . "fmt"
import "net"
func main() {
Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil {
if m, e := Decrypt(k, m, []byte("served")); e == nil {
Println(string(m))
}
}
})
}
go for the paranoid network programmer slideshare.net/feyeleanor181
package main
import "crypto/rand"
import "crypto/rsa"
import "crypto/sha1"
func Decrypt(key *rsa.PrivateKey, m, l []byte) ([]byte, error) {
return rsa.DecryptOAEP(sha1.New(), rand.Reader, key, m, l)
}
go for the paranoid network programmer slideshare.net/feyeleanor182
package main
import "crypto/rsa"
import . "fmt"
import "net"
func main() {
Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil {
if m, e := Decrypt(k, m, []byte("served")); e == nil {
Println(string(m))
}
}
})
}
go for the paranoid network programmer slideshare.net/feyeleanor183
package main
import "crypto/rsa"
import . "fmt"
import "net"
func main() {
Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil {
if m, e := Decrypt(k, m, []byte("served")); e == nil {
Println(string(m))
}
}
})
}
go for the paranoid network programmer slideshare.net/feyeleanor184
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor185
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor186
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor187
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor188
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor189
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor190
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor191
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor192
package main
import "crypto/rsa"
import "crypto/x509"
import "encoding/pem"
import "io/ioutil"
func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) {
if file, e := ioutil.ReadFile(file); e == nil {
if block, _ := pem.Decode(file); block != nil {
if block.Type == "RSA PRIVATE KEY" {
r, e = x509.ParsePKCS1PrivateKey(block.Bytes)
}
}
}
return
}
go for the paranoid network programmer slideshare.net/feyeleanor193
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor194
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor195
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor196
package main
import "bytes"
import “crypto/rsa"
import "encoding/gob"
import "net"
func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) {
var b bytes.Buffer
if e := gob.NewEncoder(&b).Encode(k); e == nil {
if _, e = c.Write(b.Bytes()); e == nil {
f()
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor197
package main
import "bytes"
import “crypto/rsa"
import "encoding/gob"
import "net"
func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) {
var b bytes.Buffer
if e := gob.NewEncoder(&b).Encode(k); e == nil {
if _, e = c.Write(b.Bytes()); e == nil {
f()
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor198
package main
import "bytes"
import “crypto/rsa"
import "encoding/gob"
import "net"
func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) {
var b bytes.Buffer
if e := gob.NewEncoder(&b).Encode(k); e == nil {
if _, e = c.Write(b.Bytes()); e == nil {
f()
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor199
package main
import "crypto/rsa"
import . "fmt"
import "net"
func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) {
if k, e := LoadPrivateKey(file); e == nil {
if address, e := net.ResolveUDPAddr("udp", a); e == nil {
if conn, e := net.DialUDP("udp", nil, address); e == nil {
defer conn.Close()
SendKey(conn, k.PublicKey, func() {
f(conn, k)
})
}
}
}
}
go for the paranoid network programmer slideshare.net/feyeleanor200
http://golang.org/
go for the paranoid network programmer slideshare.net/feyeleanor201
twitter://#golang
go for the paranoid network programmer slideshare.net/feyeleanor202
twitter://@feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor

Mais conteúdo relacionado

Mais procurados

An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with goEleanor McHugh
 
북스터디 디스커버리 Go 언어
북스터디 디스커버리 Go 언어북스터디 디스커버리 Go 언어
북스터디 디스커버리 Go 언어동규 이
 
EuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedEuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedPablo Enfedaque
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with GoRicardo Gerardi
 
Elixir & Phoenix - fast, concurrent and explicit
Elixir & Phoenix - fast, concurrent and explicitElixir & Phoenix - fast, concurrent and explicit
Elixir & Phoenix - fast, concurrent and explicitTobias Pfeiffer
 
Ruby to Elixir - what's great and what you might miss
Ruby to Elixir - what's great and what you might missRuby to Elixir - what's great and what you might miss
Ruby to Elixir - what's great and what you might missTobias Pfeiffer
 
FlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Developers
 
The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212Mahmoud Samir Fayed
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinAhmad Arif Faizin
 
Data Pipelines in Swift
Data Pipelines in SwiftData Pipelines in Swift
Data Pipelines in SwiftJason Larsen
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?Adam Dudczak
 
What's New in PHP 5.5
What's New in PHP 5.5What's New in PHP 5.5
What's New in PHP 5.5Corey Ballou
 

Mais procurados (20)

Going Loopy
Going LoopyGoing Loopy
Going Loopy
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
북스터디 디스커버리 Go 언어
북스터디 디스커버리 Go 언어북스터디 디스커버리 Go 언어
북스터디 디스커버리 Go 언어
 
EuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystifiedEuroPython 2015 - Decorators demystified
EuroPython 2015 - Decorators demystified
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Let's golang
Let's golangLet's golang
Let's golang
 
FPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixirFPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixir
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
 
Elixir & Phoenix - fast, concurrent and explicit
Elixir & Phoenix - fast, concurrent and explicitElixir & Phoenix - fast, concurrent and explicit
Elixir & Phoenix - fast, concurrent and explicit
 
Ruby to Elixir - what's great and what you might miss
Ruby to Elixir - what's great and what you might missRuby to Elixir - what's great and what you might miss
Ruby to Elixir - what's great and what you might miss
 
FlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Android App Development
FlashAir Android App Development
 
Meck
MeckMeck
Meck
 
The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlin
 
Data Pipelines in Swift
Data Pipelines in SwiftData Pipelines in Swift
Data Pipelines in Swift
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
Introduction to Go for Java Programmers
Introduction to Go for Java ProgrammersIntroduction to Go for Java Programmers
Introduction to Go for Java Programmers
 
What's New in PHP 5.5
What's New in PHP 5.5What's New in PHP 5.5
What's New in PHP 5.5
 
Data structures
Data structuresData structures
Data structures
 

Semelhante a Go for the paranoid network programmer, 2nd edition

Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmerEleanor McHugh
 
Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmerEleanor McHugh
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with goHean Hong Leong
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transportsEleanor McHugh
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8Ali Habeeb
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Samuel Lampa
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminarygo-lang
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of GoFrank Müller
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...DynamicInfraDays
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Ismael Celis
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with VarnishVarnish Software
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13Rafael Dohms
 
Scala & sling
Scala & slingScala & sling
Scala & slingmichid
 
Twisted logic
Twisted logicTwisted logic
Twisted logicashfall
 
Remote Notifications
Remote NotificationsRemote Notifications
Remote NotificationsJosef Cacek
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 

Semelhante a Go for the paranoid network programmer, 2nd edition (20)

Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmer
 
Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmer
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
 
goatwork2014
goatwork2014goatwork2014
goatwork2014
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with Varnish
 
Introduction to asyncio
Introduction to asyncioIntroduction to asyncio
Introduction to asyncio
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
Scala & sling
Scala & slingScala & sling
Scala & sling
 
Twisted logic
Twisted logicTwisted logic
Twisted logic
 
Remote Notifications
Remote NotificationsRemote Notifications
Remote Notifications
 
OWASP Proxy
OWASP ProxyOWASP Proxy
OWASP Proxy
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 

Mais de Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored SpacesEleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignEleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by designEleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trustEleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleEleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goEleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor McHugh
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CEleanor McHugh
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and GoEleanor McHugh
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirementEleanor McHugh
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoEleanor McHugh
 

Mais de Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirement
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and Go
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
 

Último

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 

Último (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 

Go for the paranoid network programmer, 2nd edition

  • 1. go for the paranoid network programmer @feyeleanor 1go for the paranoid network programmer slideshare.net/feyeleanor
  • 2. twitter://@feyeleanor go for the paranoid network programmer slideshare.net/feyeleanor
  • 3. high voltage networking concurrency cryptography go for the paranoid network programmer slideshare.net/feyeleanor
  • 4. http 4go for the paranoid network programmer slideshare.net/feyeleanor
  • 5. package main import ( . "fmt" "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { http.HandleFunc("/hello", Hello) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor5
  • 6. package main import ( . "fmt" "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { http.HandleFunc("/hello", Hello) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor6
  • 7. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor7
  • 8. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor8
  • 9. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor9
  • 10. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor10
  • 11. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor11
  • 12. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the paranoid network programmer slideshare.net/feyeleanor12
  • 13. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) }) ListenAndServe(ADDRESS, nil) } go for the paranoid network programmer slideshare.net/feyeleanor13
  • 14. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) }) ListenAndServe(ADDRESS, nil) } go for the paranoid network programmer slideshare.net/feyeleanor14
  • 15. https 15go for the paranoid network programmer slideshare.net/feyeleanor
  • 16. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the paranoid network programmer slideshare.net/feyeleanor16
  • 17. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the paranoid network programmer slideshare.net/feyeleanor17
  • 18. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the paranoid network programmer slideshare.net/feyeleanor18
  • 19. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the paranoid network programmer slideshare.net/feyeleanor19
  • 20. multiple http servers 20go for the paranoid network programmer slideshare.net/feyeleanor
  • 21. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor21
  • 22. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor22
  • 23. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor23
  • 24. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor24
  • 25. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor25
  • 26. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor26
  • 27. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor27
  • 28. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor28
  • 29. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the paranoid network programmer slideshare.net/feyeleanor29
  • 30. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn( func() { ListenAndServe(":1024", nil) }, func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }, ) } go for the paranoid network programmer slideshare.net/feyeleanor30
  • 31. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) } go for the paranoid network programmer slideshare.net/feyeleanor31
  • 32. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor32
  • 33. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor33
  • 34. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor34
  • 35. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for _, _ = range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor35
  • 36. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor36
  • 37. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) <- done } } go for the paranoid network programmer slideshare.net/feyeleanor37
  • 38. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor38
  • 39. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor39
  • 40. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor40
  • 41. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor41
  • 42. waitgroups 42go for the paranoid network programmer slideshare.net/feyeleanor
  • 43. package main import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor43
  • 44. package main import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor44
  • 45. package main import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor45
  • 46. package main import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor46
  • 47. package main import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor47
  • 48. package main import ( . "fmt" . "net/http" "sync" ) var servers sync.WaitGroup func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor48
  • 49. package main import ( . "fmt" . "net/http" "sync" ) var servers sync.WaitGroup func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor49
  • 50. package main func Spawn(f ...func()) { for _, s := range f { servers.Add(1) go func(server func()) { defer servers.Done() server() }(s) } } go for the paranoid network programmer slideshare.net/feyeleanor50
  • 51. package main func Spawn(f ...func()) { for _, s := range f { servers.Add(1) go func(server func()) { defer servers.Done() server() }(s) } } go for the paranoid network programmer slideshare.net/feyeleanor51
  • 52. tcp server 52go for the paranoid network programmer slideshare.net/feyeleanor
  • 53. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor53
  • 54. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor54
  • 55. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor55
  • 56. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor56
  • 57. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor57
  • 58. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor58
  • 59. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor59
  • 60. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor60
  • 61. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor61
  • 62. tcp client 62go for the paranoid network programmer slideshare.net/feyeleanor
  • 63. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor63
  • 64. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor64
  • 65. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor65
  • 66. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor66
  • 67. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor67
  • 68. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the paranoid network programmer slideshare.net/feyeleanor68
  • 69. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the paranoid network programmer slideshare.net/feyeleanor69
  • 70. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the paranoid network programmer slideshare.net/feyeleanor70
  • 71. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the paranoid network programmer slideshare.net/feyeleanor71
  • 72. tcp/tls server 72go for the paranoid network programmer slideshare.net/feyeleanor
  • 73. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor73
  • 74. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor74
  • 75. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor75
  • 76. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor76
  • 77. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor77
  • 78. package main import "crypto/rand" import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the paranoid network programmer slideshare.net/feyeleanor78
  • 79. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor79
  • 80. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor80
  • 81. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor81
  • 82. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor82
  • 83. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor83
  • 84. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the paranoid network programmer slideshare.net/feyeleanor84
  • 85. package main import "crypto/tls" import "net" func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() f(c) }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor85
  • 86. package main import "crypto/tls" import "net" func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() f(c) }(connection) } } } } go for the paranoid network programmer slideshare.net/feyeleanor86
  • 87. package main import "crypto/tls" import "net" func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if c, e := listener.Accept(); e == nil { go Handle(c, f) } } } } func Handle(c net.Conn, f func(net.Conn)) { defer c.Close() f(c) } go for the paranoid network programmer slideshare.net/feyeleanor87
  • 88. tcp/tls client 88go for the paranoid network programmer slideshare.net/feyeleanor
  • 89. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor89
  • 90. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor90
  • 91. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor91
  • 92. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor92
  • 93. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor93
  • 94. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the paranoid network programmer slideshare.net/feyeleanor94
  • 95. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close() f(c) } } go for the paranoid network programmer slideshare.net/feyeleanor95
  • 96. package main import "bufio" import "crypto/tls" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close() f(c) } } go for the paranoid network programmer slideshare.net/feyeleanor96
  • 97. udp serve 97go for the paranoid network programmer slideshare.net/feyeleanor
  • 98. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor98
  • 99. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor99
  • 100. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor100
  • 101. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor101
  • 102. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor102
  • 103. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor103
  • 104. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor104
  • 105. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor105
  • 106. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor106
  • 107. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor107
  • 108. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor108
  • 109. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor109
  • 110. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor110
  • 111. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor111
  • 112. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor112
  • 113. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor113
  • 114. package main import "net" func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n]) } } } go for the paranoid network programmer slideshare.net/feyeleanor114
  • 115. udp request 115go for the paranoid network programmer slideshare.net/feyeleanor
  • 116. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor116
  • 117. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor117
  • 118. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor118
  • 119. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor119
  • 120. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor120
  • 121. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor121
  • 122. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor122
  • 123. aes encrypt 123go for the paranoid network programmer slideshare.net/feyeleanor
  • 124. go for the paranoid network programmer slideshare.net/feyeleanor124 package main import "net" const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a) } }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serve } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serve }
  • 125. go for the paranoid network programmer slideshare.net/feyeleanor125 package main import "net" const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a) } }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serve } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serve }
  • 126. go for the paranoid network programmer slideshare.net/feyeleanor126 package main import "net" const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a) } }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serve } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serve }
  • 127. go for the paranoid network programmer slideshare.net/feyeleanor127 package main import "net" const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a) } }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serve } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serve }
  • 128. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor128
  • 129. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor129
  • 130. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor130
  • 131. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor131
  • 132. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor132
  • 133. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor133
  • 134. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor134
  • 135. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor135
  • 136. package main import "crypto/aes" import "crypto/cipher" func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b) } } return } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m...) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!!! } return } go for the paranoid network programmer slideshare.net/feyeleanor136
  • 137. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor137
  • 138. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor138
  • 139. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor139
  • 140. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor140
  • 141. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor141
  • 142. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor142
  • 143. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor143
  • 144. package main import "crypto/aes" import "crypto/cipher" func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b)) copy(o, IV()) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]) enc.CryptBlocks(o[aes.BlockSize:], b) return } func IV() (b []byte) { b = make([]byte, aes.BlockSize) if _, e := rand.Read(b); e != nil { panic(e) } return } go for the paranoid network programmer slideshare.net/feyeleanor144
  • 145. aes decrypt 145go for the paranoid network programmer slideshare.net/feyeleanor
  • 146. package main import . "fmt" import "net" const AES_KEY = "0123456789012345" func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m) } }) }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the paranoid network programmer slideshare.net/feyeleanor146
  • 147. package main import . "fmt" import "net" const AES_KEY = "0123456789012345" func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m) } }) }) } func Dial(a string, f func(net.Conn)) { // see udp request } go for the paranoid network programmer slideshare.net/feyeleanor147
  • 148. package main import . "fmt" import "net" const AES_KEY = "0123456789012345" func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m) } }) }) } func Dial(a string, f func(net.Conn)) { // see udp request } go for the paranoid network programmer slideshare.net/feyeleanor148
  • 149. package main import . "fmt" import "net" const AES_KEY = "0123456789012345" func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m) } }) }) } func Dial(a string, f func(net.Conn)) { // see udp request } go for the paranoid network programmer slideshare.net/feyeleanor149
  • 150. package main import "net" func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { f(m[:n]) } } return } go for the paranoid network programmer slideshare.net/feyeleanor150
  • 151. package main import "net" func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { f(m[:n]) } } return } go for the paranoid network programmer slideshare.net/feyeleanor151
  • 152. package main import "net" func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { f(m[:n]) } } return } go for the paranoid network programmer slideshare.net/feyeleanor152
  • 153. package main import "net" func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { f(m[:n]) } } return } go for the paranoid network programmer slideshare.net/feyeleanor153
  • 154. package main import "net" func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { f(m[:n]) } } return } go for the paranoid network programmer slideshare.net/feyeleanor154
  • 155. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor155
  • 156. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor156
  • 157. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor157
  • 158. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor158
  • 159. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor159
  • 160. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor160
  • 161. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor161
  • 162. package main import "crypto/cipher" import "crypto/aes" func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byte iv, m = Unpack(m) c := cipher.NewCBCDecrypter(b, iv) r = make([]byte, len(m)) c.CryptBlocks(r, m) } return } func Unpack(m []byte) (iv, r []byte){ return m[:aes.BlockSize], m[aes.BlockSize:] } go for the paranoid network programmer slideshare.net/feyeleanor162
  • 163. rsa encrypt 163go for the paranoid network programmer slideshare.net/feyeleanor
  • 164. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor164
  • 165. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor165
  • 166. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor166
  • 167. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor167
  • 168. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor168
  • 169. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor169
  • 170. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor170
  • 171. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor171
  • 172. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the paranoid network programmer slideshare.net/feyeleanor172
  • 173. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor173
  • 174. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor174
  • 175. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor175
  • 176. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor176
  • 177. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor177
  • 178. rsa decrypt 178go for the paranoid network programmer slideshare.net/feyeleanor
  • 179. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the paranoid network programmer slideshare.net/feyeleanor179
  • 180. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the paranoid network programmer slideshare.net/feyeleanor180
  • 181. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the paranoid network programmer slideshare.net/feyeleanor181
  • 182. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Decrypt(key *rsa.PrivateKey, m, l []byte) ([]byte, error) { return rsa.DecryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the paranoid network programmer slideshare.net/feyeleanor182
  • 183. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the paranoid network programmer slideshare.net/feyeleanor183
  • 184. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the paranoid network programmer slideshare.net/feyeleanor184
  • 185. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor185
  • 186. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor186
  • 187. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor187
  • 188. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor188
  • 189. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor189
  • 190. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor190
  • 191. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor191
  • 192. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor192
  • 193. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the paranoid network programmer slideshare.net/feyeleanor193
  • 194. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor194
  • 195. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor195
  • 196. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor196
  • 197. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the paranoid network programmer slideshare.net/feyeleanor197
  • 198. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the paranoid network programmer slideshare.net/feyeleanor198
  • 199. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the paranoid network programmer slideshare.net/feyeleanor199
  • 200. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the paranoid network programmer slideshare.net/feyeleanor200
  • 201. http://golang.org/ go for the paranoid network programmer slideshare.net/feyeleanor201
  • 202. twitter://#golang go for the paranoid network programmer slideshare.net/feyeleanor202
  • 203. twitter://@feyeleanor go for the paranoid network programmer slideshare.net/feyeleanor