aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/farsightsec/golang-framestream/Decoder.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/farsightsec/golang-framestream/Decoder.go')
-rw-r--r--vendor/github.com/farsightsec/golang-framestream/Decoder.go154
1 files changed, 0 insertions, 154 deletions
diff --git a/vendor/github.com/farsightsec/golang-framestream/Decoder.go b/vendor/github.com/farsightsec/golang-framestream/Decoder.go
deleted file mode 100644
index e9cda8031..000000000
--- a/vendor/github.com/farsightsec/golang-framestream/Decoder.go
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2014 by Farsight Security, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package framestream
-
-import (
- "bufio"
- "encoding/binary"
- "io"
-)
-
-type DecoderOptions struct {
- MaxPayloadSize uint32
- ContentType []byte
- Bidirectional bool
-}
-
-type Decoder struct {
- buf []byte
- opt DecoderOptions
- reader *bufio.Reader
- writer *bufio.Writer
- stopped bool
-}
-
-func NewDecoder(r io.Reader, opt *DecoderOptions) (dec *Decoder, err error) {
- if opt == nil {
- opt = &DecoderOptions{}
- }
- if opt.MaxPayloadSize == 0 {
- opt.MaxPayloadSize = DEFAULT_MAX_PAYLOAD_SIZE
- }
- dec = &Decoder{
- buf: make([]byte, opt.MaxPayloadSize),
- opt: *opt,
- reader: bufio.NewReader(r),
- writer: nil,
- }
-
- var cf ControlFrame
- if opt.Bidirectional {
- w, ok := r.(io.Writer)
- if !ok {
- return dec, ErrType
- }
- dec.writer = bufio.NewWriter(w)
-
- // Read the ready control frame.
- err = cf.DecodeTypeEscape(dec.reader, CONTROL_READY)
- if err != nil {
- return
- }
-
- // Check content type.
- if !cf.MatchContentType(dec.opt.ContentType) {
- return dec, ErrContentTypeMismatch
- }
-
- // Send the accept control frame.
- accept := ControlAccept
- accept.SetContentType(dec.opt.ContentType)
- err = accept.EncodeFlush(dec.writer)
- if err != nil {
- return
- }
- }
-
- // Read the start control frame.
- err = cf.DecodeTypeEscape(dec.reader, CONTROL_START)
- if err != nil {
- return
- }
-
- // Check content type.
- if !cf.MatchContentType(dec.opt.ContentType) {
- return dec, ErrContentTypeMismatch
- }
-
- return
-}
-
-func (dec *Decoder) readFrame(frameLen uint32) (err error) {
- // Enforce limits on frame size.
- if frameLen > dec.opt.MaxPayloadSize {
- err = ErrDataFrameTooLarge
- return
- }
-
- // Read the frame.
- n, err := io.ReadFull(dec.reader, dec.buf[0:frameLen])
- if err != nil || uint32(n) != frameLen {
- return
- }
- return
-}
-
-func (dec *Decoder) Decode() (frameData []byte, err error) {
- if dec.stopped {
- err = EOF
- return
- }
-
- // Read the frame length.
- var frameLen uint32
- err = binary.Read(dec.reader, binary.BigEndian, &frameLen)
- if err != nil {
- return
- }
- if frameLen == 0 {
- // This is a control frame.
- var cf ControlFrame
- err = cf.Decode(dec.reader)
- if err != nil {
- return
- }
- if cf.ControlType == CONTROL_STOP {
- dec.stopped = true
- if dec.opt.Bidirectional {
- ff := &ControlFrame{ControlType: CONTROL_FINISH}
- err = ff.EncodeFlush(dec.writer)
- if err != nil {
- return
- }
- }
- return nil, EOF
- }
- if err != nil {
- return nil, err
- }
-
- } else {
- // This is a data frame.
- err = dec.readFrame(frameLen)
- if err != nil {
- return
- }
- frameData = dec.buf[0:frameLen]
- }
-
- return
-}
ornode Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/packages/renderers/renderer-react (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2021-11-19[ci] yarn formatGravatar matthewp 1-1/+1
2021-11-19Fix blog example (#1910)Gravatar Matthew Phillips 1-1/+1
2021-11-19Version Packages (next) (#1907)astro@0.21.0-next.10Gravatar github-actions[bot] 23-21/+28
2021-11-19Remove further dependence on vite package (#1906)Gravatar Matthew Phillips 3-5/+9
2021-11-19Version Packages (next) (#1904)astro@0.21.0-next.9Gravatar github-actions[bot] 23-21/+30
2021-11-19Remove OSX \x00 workaround (#1901)Gravatar Matthew Phillips 2-5/+5
2021-11-19Resolve vite client modules to vendored vite (#1903)Gravatar Matthew Phillips 2-2/+7
2021-11-19[ci] yarn formatGravatar matthewp 1-3/+3
2021-11-19Add Debug tests (#1882)Gravatar Matthew Phillips 4-0/+62
2021-11-19[ci] collect statsGravatar FredKSchott 1-0/+1
2021-11-19Version Packages (next) (#1881)astro@0.21.0-next.8@astrojs/renderer-vue@0.2.0-next.2Gravatar github-actions[bot] 25-23/+42
2021-11-18Improve HMR (#1896)Gravatar Drew Powers 2-10/+18
2021-11-18update depsGravatar Fred K. Schott 5-352/+65
2021-11-18fix #1778Gravatar Fred K. Schott 2-1/+8
2021-11-18Update compiler (#1869)Gravatar Nate Moore 3-11/+6
2021-11-18remove unused remark dependency (#1894)Gravatar Fred K. Schott 2-245/+13
2021-11-18Improve error messages (#1875)Gravatar Drew Powers 39-61/+448
2021-11-18pin astro compiler to older versionGravatar Fred K. Schott 2-5/+5
2021-11-18Update yarn.lock to reflect the state of the package.json files (#1892)Gravatar Jonathan Neal 5-1300/+1000
2021-11-19[ci] yarn formatGravatar FredKSchott 1-5/+3