Skip to content

Commit 491bb4b

Browse files
committed
Make fast write duration as a configuration item
1 parent 23ce945 commit 491bb4b

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

protocol/baboon/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var Conf = struct {
2727
// that you are using a proxy server.
2828
Masker string
2929
}{
30-
Masker: "https://github.com/",
30+
Masker: "https://github.com",
3131
}
3232

3333
// Server implemented the baboon protocol.

protocol/czar/engine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ import (
4141
// | Sid | 2 | 0/1 | Rsv |
4242
// +-----+-----+-----+-----+
4343

44+
// Conf is acting as package level configuration.
45+
var Conf = struct {
46+
// The newly created stream has a higher write priority.
47+
FastWriteDuration time.Duration
48+
}{
49+
FastWriteDuration: time.Second * 8,
50+
}
51+
4452
// Server implemented the czar protocol.
4553
type Server struct {
4654
Cipher []byte

protocol/czar/mux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212

1313
// A Stream managed by the multiplexer.
1414
type Stream struct {
15+
fwd time.Time
1516
idx uint8
1617
mux *Mux
17-
qtw time.Time
1818
rbf []byte
1919
rch chan []byte
2020
rer *Err
@@ -105,7 +105,7 @@ func (s *Stream) Write(p []byte) (int, error) {
105105
binary.BigEndian.PutUint16(buf[2:4], uint16(l))
106106
copy(buf[4:], p[:l])
107107
p = p[l:]
108-
if time.Now().After(s.qtw) {
108+
if time.Now().After(s.fwd) {
109109
z = 2
110110
}
111111
err := s.mux.pri.Pri(z, func() error {
@@ -129,9 +129,9 @@ func (s *Stream) Write(p []byte) (int, error) {
129129
// NewStream returns a new Stream.
130130
func NewStream(idx uint8, mux *Mux) *Stream {
131131
return &Stream{
132+
fwd: time.Now().Add(Conf.FastWriteDuration),
132133
idx: idx,
133134
mux: mux,
134-
qtw: time.Now().Add(time.Second * 8),
135135
rbf: make([]byte, 0),
136136
rch: make(chan []byte, 32),
137137
rer: NewErr(),

0 commit comments

Comments
 (0)