Skip to content

Commit 83cdb2d

Browse files
committed
rename package
1 parent 6740553 commit 83cdb2d

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

internal/tlsstate/controlmsg.go renamed to internal/tlssession/controlmsg.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tlsstate
1+
package tlssession
22

33
import (
44
"bytes"
@@ -10,6 +10,16 @@ import (
1010
"github.com/ooni/minivpn/internal/session"
1111
)
1212

13+
//
14+
// The functions in this file deal with control messages. These control
15+
// messages are sent and received over the TLS session once we've gone one
16+
// established.
17+
//
18+
// The control **channel** below us will deal with serializing and deserializing them,
19+
// what we receive at this stage are the cleartext payloads obtained after decrypting
20+
// an application data TLS record.
21+
//
22+
1323
// encodeClientControlMessage returns a byte array with the payload for a control channel packet.
1424
// This is the packet that the client sends to the server with the key
1525
// material, local options and credentials (if username+password authentication is used).

internal/tlssession/doc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Package tlssession performs a TLS handshake over the control channel, and then it
2+
// exchanges keys with the server over this secure channel.
3+
package tlssession

internal/tlsstate/tlsbio.go renamed to internal/tlssession/tlsbio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tlsstate
1+
package tlssession
22

33
import (
44
"bytes"

internal/tlsstate/tlshandshake.go renamed to internal/tlssession/tlshandshake.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package tlsstate
1+
package tlssession
22

33
import (
44
"crypto/x509"
55
"encoding/hex"
66
"errors"
77
"fmt"
8-
"io/ioutil"
98
"net"
9+
"os"
1010

1111
"github.com/ooni/minivpn/internal/model"
1212
"github.com/ooni/minivpn/internal/runtimex"
@@ -55,7 +55,7 @@ type certPaths struct {
5555
// the passed certPaths and return a certConfig with the client and CA certificates.
5656
func loadCertAndCAFromPath(pth certPaths) (*certConfig, error) {
5757
ca := x509.NewCertPool()
58-
caData, err := ioutil.ReadFile(pth.caPath)
58+
caData, err := os.ReadFile(pth.caPath)
5959
if err != nil {
6060
return nil, fmt.Errorf("%w: %s", ErrBadCA, err)
6161
}
@@ -228,6 +228,7 @@ type handshaker interface {
228228
// is, the default tls.Client factory; and an error.
229229
// we're not using the default factory right now, but it comes handy to be able
230230
// to compare the fingerprints with a golang TLS handshake.
231+
// TODO(ainghazal): implement some sort of test that extracts/compares the TLS client hello.
231232
func defaultTLSFactory(conn net.Conn, config *tls.Config) (handshaker, error) {
232233
c := tls.Client(conn, config)
233234
return c, nil

internal/tlsstate/tlsstate.go renamed to internal/tlssession/tlssession.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tlsstate
1+
package tlssession
22

33
import (
44
"context"
@@ -11,7 +11,7 @@ import (
1111
tls "github.com/refraction-networking/utls"
1212
)
1313

14-
// Service is the tlsstate service. Make sure you initialize
14+
// Service is the tlssession service. Make sure you initialize
1515
// the channels before invoking [Service.StartWorkers].
1616
type Service struct {
1717
// NotifyTLS is a channel where we receive incoming notifications.
@@ -34,7 +34,7 @@ type Service struct {
3434
TLSRecordDown *chan []byte
3535
}
3636

37-
// StartWorkers starts the tls-state workers. See the [ARCHITECTURE]
37+
// StartWorkers starts the tlssession workers. See the [ARCHITECTURE]
3838
// file for more information about the packet-muxer workers.
3939
//
4040
// [ARCHITECTURE]: https://github.com/ooni/minivpn/blob/main/ARCHITECTURE.md
@@ -69,21 +69,21 @@ type workersState struct {
6969
workersManager *workers.Manager
7070
}
7171

72-
// worker is the main loop of the tlsstate
72+
// worker is the main loop of the tlssession
7373
func (ws *workersState) worker() {
7474
defer func() {
7575
ws.workersManager.OnWorkerDone()
7676
ws.workersManager.StartShutdown()
77-
ws.logger.Debug("tlsstate: worker: done")
77+
ws.logger.Debug("tlssession: worker: done")
7878
}()
7979

80-
ws.logger.Debug("tlsstate: worker: started")
80+
ws.logger.Debug("tlssession: worker: started")
8181
for {
8282
select {
8383
case notif := <-ws.notifyTLS:
8484
if (notif.Flags & model.NotificationReset) != 0 {
8585
if err := ws.tlsAuth(); err != nil {
86-
ws.logger.Warnf("tlsstate: tlsAuth: %s", err.Error())
86+
ws.logger.Warnf("tlssession: tlsAuth: %s", err.Error())
8787
// TODO: is it worth checking the return value and stopping?
8888
}
8989
}
@@ -135,8 +135,8 @@ func (ws *workersState) tlsAuth() error {
135135
// doTLSAuth is the internal implementation of tlsAuth such that tlsAuth
136136
// can interrupt this function early if needed.
137137
func (ws *workersState) doTLSAuth(conn net.Conn, config *tls.Config, errorch chan<- error) {
138-
ws.logger.Debug("tlsstate: doTLSAuth: started")
139-
defer ws.logger.Debug("tlsstate: doTLSAuth: done")
138+
ws.logger.Debug("tlsession: doTLSAuth: started")
139+
defer ws.logger.Debug("tlssession: doTLSAuth: done")
140140

141141
// do the TLS handshake
142142
tlsConn, err := tlsHandshakeFn(conn, config)

internal/tlsstate/doc.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)