mnightingale / rapidyenc Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
First of all, nice work here ;).
I´m trying to use the library to decode a yenc segment but I always end up with an transform.ErrShortSrc.
The segments that I get are encoded following this code:
`go
buf := &bytes.Buffer{}
buf.WriteString(fmt.Sprintf("From: %s\r\n", data.poster))
buf.WriteString(fmt.Sprintf("Newsgroups: %s\r\n", data.group))
buf.WriteString(fmt.Sprintf("Message-ID: <%s>\r\n", data.msgId))
buf.WriteString("X-Newsposter: xxxxx\r\n")
// Build subject
subj := fmt.Sprintf(
"[%d/%d] - \"%s\" yEnc (%d/%d)",
data.fileNum,
data.fileTotal,
data.fileName,
data.partNum,
data.partTotal,
)
buf.WriteString(fmt.Sprintf("Subject: %s\r\n\r\n", subj))
// yEnc begin line
// yEnc begin line
buf.WriteString(fmt.Sprintf(
"=ybegin part=%d total=%d line=128 size=%d name=%s\r\n",
data.partNum,
data.partTotal,
data.fileSize,
data.fileName,
))
// yEnc part line
buf.WriteString(fmt.Sprintf("=ypart begin=%d end=%d\r\n", data.partBegin+1, data.partEnd))
// Encoded data
err := yenc.Encode(p, buf)
if err != nil {
return nil, err
}
// yEnc end line
h := crc32.NewIEEE()
h.Write(p)
buf.WriteString(fmt.Sprintf("=yend size=%d part=%d pcrc32=%08X\r\n", data.partSize, data.partNum, h.Sum32()))
`
Then I just decode it by input the segment read from the Usenet provider.
Like here https://github.com/javi11/usenet-drive/blob/dbb86388ad2648590442335512c8dd6f90b37212/internal/usenet/filereader/buffer.go#L289. Right now I´m using another implementation of yenc decoder.
Could you please guide on how to use the library?
Thanks
I think there may be a memory leak on the decoder. Under high pressure, decoders are being created, but they are never released, so the decoders pool grows without control.
Maybe a limit is needed or a way to clean up
Hey, there is a special case that is causing me an error using the library:
I see that when src Is equals to yend size=750000 part=8525 pcrc32=ACBE5763\r\n.\r\n
The values returned by decodedDecremental are
nd: 0 ns: 1 end: 1
With these values, this part of the code:
Line 191 in 8792729
panic: runtime error: slice bounds out of range [-1:] goroutine 474 [running]: github.com/mnightingale/rapidyenc.(*Decoder).Transform(0xc0002465a0, {0xc002af3000, 0x1000, 0x1000}, {0xc000172000, 0x2c, 0x1000}, 0x0) /go/pkg/mod/github.com/mnightingale/[email protected]/decoder.go:206 +0x915 github.com/mnightingale/rapidyenc.(*Decoder).Read(0xc0002465a0, {0xc0045651b0, 0x20e50, 0xc0002465a0?}) /go/pkg/mod/github.com/mnightingale/[email protected]/decoder.go:142
I solved by adding a check after the switch case in which
if nSrc < 0 { return nDst, 1, io.EOF }
But not sure if is correct or not because I don't fully understand the code. Do you think is a good solution? I can do a pr for it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.