Skip to content

Commit 5345b80

Browse files
committed
initial commit h3/ws based media transport
1 parent 0263ff2 commit 5345b80

19 files changed

+1568
-28
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14-
# Dependency directories (remove the comment below to include it)
15-
# vendor/
14+
15+
./idea
16+
./idea/*

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# goRIPT
2-
Implementation of RIPT in golang
1+
# http-media
2+
WIP and in hack mode (except few landmines and no-so optimized code)
3+
4+
Components
5+
----------
6+
7+
## Server
8+
- Media router (ript_net) and server.go (driver program)
9+
- Implements websockets and h3/quic transports
10+
- Distributes media from sender to all the receivers
11+
12+
## Client
13+
- Support WS and h3/quic transport (selected via command line flag)
14+
- Implements unidirectional media (sender -> reciever(s))
15+
16+
Note: At present, self-signed certs are used to quic tls setup.
17+
18+
Note: Current code shows how h3 POST can be used to send/recv media for h3 transport.
19+
20+
# Build and Run
21+
22+
## Prerequisites
23+
24+
1. quic-go (go get tgithub.com/lucas-clemente/quic-go)
25+
26+
27+
## Run server:
28+
``` go run server/main.go ```
29+
30+
## Run Client (s)
31+
```
32+
cd ript_client
33+
go build .
34+
```
35+
36+
### H3 Sender -> H3 Receiver
37+
```
38+
./rip_client --mode=pull --xport=h3 (receiver)
39+
40+
./rip_client --mode=push --xport=h3 (sender)
41+
```
42+
43+
### WS Sender -> H3 Receiver
44+
```
45+
./rip_client --mode=pull --xport=h3 (receiver)
46+
47+
./rip_client --mode=push --xport=ws (sender)
48+
```
49+
50+
51+

TODO.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# TODOs
2+
1. combine grpc server with ws and h3 server
3+
2. Support bi-directional media
4+
3. See if the media latency can be improved
5+
4. Non-golang client
6+
5. tighten loose ends
7+
6. Occasional portaudio crashes
8+
7. Define media and control framing
9+
8. tests/tests/tests

common/ca.pem

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIC0DCCAbgCCQCmiwJpSoekpDANBgkqhkiG9w0BAQsFADAqMRMwEQYDVQQKDApx
3+
dWljLWdvIENBMRMwEQYDVQQLDApxdWljLWdvIENBMB4XDTE4MTIwODA2NDIyMVoX
4+
DTI4MTIwNTA2NDIyMVowKjETMBEGA1UECgwKcXVpYy1nbyBDQTETMBEGA1UECwwK
5+
cXVpYy1nbyBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN5MxI09
6+
i01xRON732BFIuxO2SGjA9jYkvUvNXK886gifp2BfWLcOW1DHkXxBnhWMqfpcIWM
7+
GviF4G2Mp0HEJDMe+4LBxje/1e2WA+nzQlIZD6LaDi98nXJaAcCMM4a64Vm0i8Z3
8+
+4c+O93+5TekPn507nl7QA1IaEEtoek7w7wDw4ZF3ET+nns2HwVpV/ugfuYOQbTJ
9+
8Np+zO8EfPMTUjEpKdl4bp/yqcouWD+oIhoxmx1V+LxshcpSwtzHIAi6gjHUDCEe
10+
bk5Y2GBT4VR5WKmNGvlfe9L0Gn0ZLJoeXDshrunF0xEmSv8MxlHcKH/u4IHiO+6x
11+
+5sdslqY7uEPEhkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhvXUMiatkgsnoRHc
12+
UobKraGttETivxvtKpc48o1TSkR+kCKbMnygmrvc5niEqc9iDg8JI6HjBKJ3/hfA
13+
uKdyiR8cQNcQRgJ/3FVx0n3KGDUbHJSuIQzFvXom2ZPdlAHFqAT+8AVrz42v8gct
14+
gyiGdFCSNisDbevOiRHuJtZ0m8YsGgtfU48wqGOaSSsRz4mYD6kqBFd0+Ja3/EGv
15+
vl24L5xMCy1zGGl6wKPa7TT7ok4TfD1YmIXOfmWYop6cTLwePLj1nHrLi0AlsSn1
16+
2pFlosc9/qEbO5drqNoxUZfeF0L9RUSuArHRSO779dW/AmOtFdK3yaBGqflg0r7p
17+
lYombA==
18+
-----END CERTIFICATE-----

common/cert.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package common
2+
3+
import (
4+
"crypto/tls"
5+
"crypto/x509"
6+
"io/ioutil"
7+
"path"
8+
"runtime"
9+
)
10+
11+
var certPath string
12+
13+
func init() {
14+
_, filename, _, ok := runtime.Caller(0)
15+
if !ok {
16+
panic("Failed to get current frame")
17+
}
18+
19+
certPath = path.Dir(filename)
20+
}
21+
22+
// GetCertificatePaths returns the paths to certificate and key
23+
func GetCertificatePaths() (string, string) {
24+
return path.Join(certPath, "cert.pem"), path.Join(certPath, "priv.key")
25+
}
26+
27+
// GetTLSConfig returns a tls config for quic.clemente.io
28+
func GetTLSConfig() *tls.Config {
29+
cert, err := tls.LoadX509KeyPair(GetCertificatePaths())
30+
if err != nil {
31+
panic(err)
32+
}
33+
return &tls.Config{
34+
Certificates: []tls.Certificate{cert},
35+
}
36+
}
37+
38+
// AddRootCA adds the root CA certificate to a cert pool
39+
func AddRootCA(certPool *x509.CertPool) {
40+
caCertPath := path.Join(certPath, "ca.pem")
41+
caCertRaw, err := ioutil.ReadFile(caCertPath)
42+
if err != nil {
43+
panic(err)
44+
}
45+
if ok := certPool.AppendCertsFromPEM(caCertRaw); !ok {
46+
panic("Could not add root ceritificate to pool.")
47+
}
48+
}
49+
50+
// GetRootCA returns an x509.CertPool containing (only) the CA certificate
51+
func GetRootCA() *x509.CertPool {
52+
pool := x509.NewCertPool()
53+
AddRootCA(pool)
54+
return pool
55+
}

common/cert.pem

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIC3jCCAcYCCQCV4BOv+SRo4zANBgkqhkiG9w0BAQUFADAqMRMwEQYDVQQKDApx
3+
dWljLWdvIENBMRMwEQYDVQQLDApxdWljLWdvIENBMB4XDTE4MTIwODA2NDMwMloX
4+
DTI4MTIwNTA2NDMwMlowODEQMA4GA1UECgwHcXVpYy1nbzEQMA4GA1UECwwHcXVp
5+
Yy1nbzESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
6+
MIIBCgKCAQEAyc/hS8XHkOJaLrdPOSTZFUBVyHNSfQUX/3dEpmccPlLQLgopYZZO
7+
W/cVhkxAfQ3e68xKkuZKfZN5Hytn5V/AOSk281BqxFxpfCcKVYqVpDZH99+jaVfG
8+
ImPp5Y22qCnbSEwYrMTcLiK8PVa4MkpKf1KNacVlqawU+ZWI5fevAFGTtmrMJ4S+
9+
qZY7tAaVkax+OiKWWfhLQjJCsN3IIDysTfbWao6cYKgtTfqVChEddzS7LRJVRaB+
10+
+huUbB87tRBJbCuJX65yB7Fw77YiKoFjc5r2845fcS2Ew4+w29mbXoj7M7g6eup5
11+
SnCydsCvyNy6VkgaSlWS0DXvxuzWshwUrwIDAQABMA0GCSqGSIb3DQEBBQUAA4IB
12+
AQBWgmFunf44X3/NIjNvVLeQsfGW+4L/lCi2F5tqa70Hkda+xhKACnQQGB2qCSCF
13+
Jfxj4iKrFJ7+JB8GnribWthLuDq49PQrTI+1wKFd9c2b8DXzJLz4Onw+mPX97pZm
14+
TflQSIxXRaFAIQuUWNTArZZEe1ESSlnaBuE5w77LMf4GMFD3P3jzSHKUyM1sF97j
15+
gRbIt8Jw7Uyd8vlXk6m2wvO5H3hZrrhJUJH3WW13a7wLJRnff2meKU90hkLQwuxO
16+
kyh0k/h158/r2ibiahTmQEgHs9vQaCM+HXuk5P+Tzq5Zl/n0dMFZMfkqNkD4nym/
17+
nu7zfdwMlcBjKt9g3BGw+KE3
18+
-----END CERTIFICATE-----

common/cert_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package common
2+
3+
import (
4+
"crypto/tls"
5+
"io/ioutil"
6+
7+
. "github.com/onsi/ginkgo"
8+
. "github.com/onsi/gomega"
9+
)
10+
11+
var _ = Describe("certificates", func() {
12+
It("returns certificates", func() {
13+
ln, err := tls.Listen("tcp", "localhost:4433", GetTLSConfig())
14+
Expect(err).ToNot(HaveOccurred())
15+
16+
go func() {
17+
defer GinkgoRecover()
18+
conn, err := ln.Accept()
19+
Expect(err).ToNot(HaveOccurred())
20+
defer conn.Close()
21+
_, err = conn.Write([]byte("foobar"))
22+
Expect(err).ToNot(HaveOccurred())
23+
}()
24+
25+
conn, err := tls.Dial("tcp", "localhost:4433", &tls.Config{RootCAs: GetRootCA()})
26+
Expect(err).ToNot(HaveOccurred())
27+
data, err := ioutil.ReadAll(conn)
28+
Expect(err).ToNot(HaveOccurred())
29+
Expect(string(data)).To(Equal("foobar"))
30+
})
31+
})

common/license.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The code in this directory has been take from quic-go repository.
2+
3+
Here is the original license from quic-go
4+
5+
MIT License
6+
7+
Copyright (c) 2016 the quic-go authors & Google, Inc.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

common/priv.key

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIIEogIBAAKCAQEAyc/hS8XHkOJaLrdPOSTZFUBVyHNSfQUX/3dEpmccPlLQLgop
3+
YZZOW/cVhkxAfQ3e68xKkuZKfZN5Hytn5V/AOSk281BqxFxpfCcKVYqVpDZH99+j
4+
aVfGImPp5Y22qCnbSEwYrMTcLiK8PVa4MkpKf1KNacVlqawU+ZWI5fevAFGTtmrM
5+
J4S+qZY7tAaVkax+OiKWWfhLQjJCsN3IIDysTfbWao6cYKgtTfqVChEddzS7LRJV
6+
RaB++huUbB87tRBJbCuJX65yB7Fw77YiKoFjc5r2845fcS2Ew4+w29mbXoj7M7g6
7+
eup5SnCydsCvyNy6VkgaSlWS0DXvxuzWshwUrwIDAQABAoIBADunQwVO1Qqync2p
8+
SbWueqyZc8HotL1XwBw3eQdm+yZA/GBfiJPcBhWRF7+20mkkrHwuyuxZPjOYX/ki
9+
r3dRslQzJpcNckHQvy1/rMJUUJ9VnDhc1sTQuTR5LC46kX9rv/HC7JhFKIBKrDHF
10+
bHURGKxCDqLxQnfA8gJEfU7cw9HnxMxmKv7qJ3O7EHYMuTQstkYsGOr60zX/C+Zm
11+
7YA+d7nx1LpL0m2lKs70iz5MzGg+KgKyrkMWQ30gpxILBxNzzuQr7Kv/+63/3+G9
12+
nfCGeLmwGakPFpm6/GwiABE0yGa71YNAQs18iUTZwP/ZEDw3KB2SoG8wcqWjNAd+
13+
cUF2PgECgYEA5Xe/OZouw9h0NBo0Zut+HC0YOuUfY72Ug9Fm8bAS6wDuPiO3jIvK
14+
J40d+ZHNp4AakfTuugiqEDJRlV7T/F2K/KHDWvXTg5ZpAC8dsZKJMxyyAp8EniYQ
15+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