mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
roulette chaff mode functional.
TODO: corpus mode from a file rather than builtin data
This commit is contained in:
parent
adbc3e690a
commit
3d327b6b7c
1 changed files with 16 additions and 12 deletions
28
xsnet/net.go
28
xsnet/net.go
|
|
@ -69,6 +69,9 @@ type (
|
||||||
msecsMin uint //msecs min interval
|
msecsMin uint //msecs min interval
|
||||||
msecsMax uint //msecs max interval
|
msecsMax uint //msecs max interval
|
||||||
szMax uint // max size in bytes
|
szMax uint // max size in bytes
|
||||||
|
|
||||||
|
fromIdx uint // used for corpus-style fill context across
|
||||||
|
fillIdx uint // ..chaff yield calls
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conn is a connection wrapping net.Conn with KEX & session state
|
// Conn is a connection wrapping net.Conn with KEX & session state
|
||||||
|
|
@ -1563,6 +1566,8 @@ func (hc *Conn) SetupChaff(mode ChaffMode, msecsMin uint, msecsMax uint, szMax u
|
||||||
hc.chaff.mode = mode
|
hc.chaff.mode = mode
|
||||||
case ChaffConfigCorpusA:
|
case ChaffConfigCorpusA:
|
||||||
hc.chaff.mode = mode
|
hc.chaff.mode = mode
|
||||||
|
hc.chaff.fillIdx = 0
|
||||||
|
hc.chaff.fromIdx = 0
|
||||||
case ChaffConfigRoulette:
|
case ChaffConfigRoulette:
|
||||||
hc.chaff.mode = mode
|
hc.chaff.mode = mode
|
||||||
default:
|
default:
|
||||||
|
|
@ -1579,17 +1584,15 @@ func randBytes(sz uint) (r []byte) {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func fillBufferWithText(fillerMat string, sz uint) (r []byte) {
|
func fillBufferWithText(fillerMat string, sz uint, fromIdx *uint, fillIdx *uint) (r []byte) {
|
||||||
r = make([]byte, sz)
|
r = make([]byte, sz)
|
||||||
fromIdx := 0
|
for *fillIdx < sz {
|
||||||
fillIdx := uint(0)
|
if *fromIdx == uint(len(fillerMat)) {
|
||||||
for fillIdx < sz {
|
*fromIdx = /* 0 */ uint(rand.Intn(len(fillerMat)))
|
||||||
if fromIdx == len(fillerMat) {
|
|
||||||
fromIdx = /* 0 */ rand.Intn(len(fillerMat))
|
|
||||||
}
|
}
|
||||||
r[fillIdx] = fillerMat[fromIdx]
|
r[*fillIdx] = fillerMat[*fromIdx]
|
||||||
fillIdx++
|
*fillIdx++
|
||||||
fromIdx++
|
*fromIdx++
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
@ -1598,7 +1601,7 @@ func ChaffStrategy(mode ChaffMode) (s ChaffMode) {
|
||||||
if mode == ChaffConfigRoulette {
|
if mode == ChaffConfigRoulette {
|
||||||
s = ChaffMode(int(rand.Intn(ChaffConfigRoulette)))
|
s = ChaffMode(int(rand.Intn(ChaffConfigRoulette)))
|
||||||
}
|
}
|
||||||
fmt.Printf("strategy:%v\n", s)
|
//fmt.Printf("strategy:%v\n", s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1616,8 +1619,9 @@ func (hc *Conn) chaffHelper() {
|
||||||
|
|
||||||
switch strat {
|
switch strat {
|
||||||
case ChaffConfigCorpusA:
|
case ChaffConfigCorpusA:
|
||||||
bufTmp = fillBufferWithText(corpusTextA, hc.chaff.szMax)
|
bufTmp = fillBufferWithText(corpusTextA, hc.chaff.szMax, &hc.chaff.fromIdx, &hc.chaff.fillIdx)
|
||||||
case ChaffConfigRand:
|
case ChaffConfigRand:
|
||||||
|
fallthrough
|
||||||
default:
|
default:
|
||||||
bufTmp = randBytes(hc.chaff.szMax)
|
bufTmp = randBytes(hc.chaff.szMax)
|
||||||
}
|
}
|
||||||
|
|
@ -1652,6 +1656,6 @@ attempting to decode a live or recorded xs session you should note that this cha
|
||||||
text will probably give you no end of difficulties, and that is by design. Have you
|
text will probably give you no end of difficulties, and that is by design. Have you
|
||||||
considered your life path? Snooping on other individuals, either domestic or foreign,
|
considered your life path? Snooping on other individuals, either domestic or foreign,
|
||||||
is an ethically questionable career and you may be doing more harm than good to democracy,
|
is an ethically questionable career and you may be doing more harm than good to democracy,
|
||||||
international relations, and general welfare of humanity. Consider buying a nice quiet
|
international relations, and the general welfare of humanity. Consider buying a nice quiet
|
||||||
cabin somewhere by a lake, growing food and spending time with those you love.`
|
cabin somewhere by a lake, growing food and spending time with those you love.`
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue