]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
fix
authorqydysky <32743305+qydysky@users.noreply.github.com>
Thu, 3 Nov 2022 17:16:58 +0000 (01:16 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Thu, 3 Nov 2022 17:16:58 +0000 (01:16 +0800)
F/B_I.go
F/B_I_test.go
F/api.go
Reply/F.go
Reply/fmp4Decode.go
Reply/stream.go
demo/config/config_K_v.json

index 4fe5de11e481026b044eeeb3acd0d122557fed11..ca3e283a1e44c6aeffa3f90a62222d246bdc852b 100644 (file)
--- a/F/B_I.go
+++ b/F/B_I.go
@@ -40,33 +40,6 @@ func Itob16(num int16) []byte {
        return buffer.Bytes()
 }
 
-func btoi64(b []byte) int64 {
-       var buffer int64
-       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
-       if err != nil {
-               p.Logf().E(err)
-       }
-       return buffer
-}
-
-func btoi32(b []byte) int32 {
-       var buffer int32
-       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
-       if err != nil {
-               p.Logf().E(err)
-       }
-       return buffer
-}
-
-func btoi16(b []byte) int16 {
-       var buffer int16
-       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
-       if err != nil {
-               p.Logf().E(err)
-       }
-       return buffer
-}
-
 func Btoi64(b []byte, offset int) int64 {
        for len(b) < 8 {
                b = append([]byte{0x00}, b...)
@@ -85,16 +58,54 @@ func Btoi(b []byte, offset int, size int) int64 {
        return btoi64(buf)
 }
 
+func Btoui32(b []byte, offset int) uint32 {
+       return btoui32(b[offset : offset+4])
+}
+
 func Btoi32(b []byte, offset int) int32 {
        for len(b) < 4 {
                b = append([]byte{0x00}, b...)
        }
-       return btoi32(b[offset : offset+4])
+       return int32(btoui32(b[offset : offset+4]))
+}
+
+func Btoui16(b []byte, offset int) uint16 {
+       for len(b) < 2 {
+               b = append([]byte{0x00}, b...)
+       }
+       return btoui16(b[offset : offset+2])
 }
 
 func Btoi16(b []byte, offset int) int16 {
        for len(b) < 2 {
                b = append([]byte{0x00}, b...)
        }
-       return btoi16(b[offset : offset+2])
+       return int16(btoui16(b[offset : offset+2]))
+}
+
+func btoi64(b []byte) int64 {
+       var buffer int64
+       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
+       if err != nil {
+               p.Logf().E(err)
+       }
+       return buffer
+}
+
+func btoui32(b []byte) uint32 {
+       var buffer uint32
+       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
+       if err != nil {
+               p.Logf().E(err)
+       }
+       return buffer
+}
+
+func btoui16(b []byte) uint16 {
+       var buffer uint16
+       err := binary.Read(bytes.NewReader(b), binary.BigEndian, &buffer)
+       if err != nil {
+               p.Logf().E(err)
+       }
+       return buffer
 }
index 05d36e61f3e1f11c83d59e038b68f95a6c8cbba4..06a8311596c913ef90239a3a719462dc231ad427 100644 (file)
@@ -3,7 +3,9 @@ package F
 import "testing"
 
 func TestBtoi32(t *testing.T) {
-       t.Log(Btoi64([]byte{0xff, 0x0f, 0xff, 0xff}, 0))
+       t.Log(int32(Btoui32([]byte{0xff, 0x0f, 0xff, 0xff}, 0)))
+       t.Log(Btoi32([]byte{0xff, 0xff, 0xff, 0xff}, 0))
+       t.Log(Btoi32([]byte{0x00, 0xff, 0xff, 0xff}, 0))
 }
 
 func TestItob32(t *testing.T) {
index b5a2e31a8201352aaf13eb1ec876dc48ce7f922e..9c0403f8a854867a4f694dab4f42701a232bfaba 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -1292,9 +1292,14 @@ func (c *GetFunc) Get_cookie() (missKey []string) {
                return
        }
 
+       scanPort := int(c.K_v.LoadV("扫码登录端口").(float64))
+       if scanPort <= 0 {
+               scanPort = sys.Sys().GetFreePort()
+       }
        var server = &http.Server{
-               Addr: "0.0.0.0:" + strconv.Itoa(sys.Sys().GetFreePort()),
+               Addr: "0.0.0.0:" + strconv.Itoa(scanPort),
        }
+
        { //生成二维码
                qr.WriteFile(img_url, qr.Medium, 256, `qr.png`)
                if !p.Checkfile().IsExist(`qr.png`) {
index 8061ea2706e88643bf7d776213e69c6e95fdb9ba..8d2d5e6a86da5753882e6bf75152402ec94b306e 100644 (file)
@@ -1162,6 +1162,11 @@ func init() {
                                                        v += "0.flv"
                                                } else if file.New(v+"0.mp4", 0, true).IsExist() {
                                                        v += "0.mp4"
+                                               } else {
+                                                       w.Header().Set("Retry-After", "1")
+                                                       w.WriteHeader(http.StatusServiceUnavailable)
+                                                       flog.L(`E: `, "未找到流文件", v)
+                                                       return
                                                }
 
                                                var rangeHeaderNum int
index b1a2880c57b5f84d9dcecb86ab1c64309de6c7c7..3dba14b24156ea78e7bc3d4128b8ebe915f0ea45 100644 (file)
@@ -284,5 +284,11 @@ func (t *Fmp4Decoder) Seach_stream_fmp4(buf []byte) (keyframes [][]byte, last_av
                keyframe = append(keyframe, buf[moofI:mdatE]...)
        }
 
+       if cu == 0 {
+               err = errors.New("未找到moof")
+       }
+       if last_avilable_offset == 0 && len(buf) > 1024*1024*20 {
+               err = errors.New("buf超过20M")
+       }
        return
 }
index c501bdc1f2bf4d95f43c9105abd35e5911ffd984..14344b76a7010f35ee3259666d46375be9b62bd0 100644 (file)
@@ -326,7 +326,7 @@ func (t *M4SStream) fetchParseM3U8() (m4s_links []*m4s_link_item, m3u8_addon []b
                        timed := tmp[len(tmp)-1].createdTime.Sub(t.last_m4s.createdTime).Seconds()
                        nos, _ := tmp[len(tmp)-1].getNo()
                        noe, _ := t.last_m4s.getNo()
-                       if math.Abs(timed-float64(nos-noe)) > 2 {
+                       if timed > 3 && math.Abs(timed-float64(nos-noe)) > 2 {
                                e = fmt.Errorf("服务器 %s 发生故障 %d 秒产出了 %d 切片", m3u8_url.Host, int(timed), nos-noe)
                                continue
                        }
index 56cc8a706073bd93af19322e8c4a26e568b8b8e8..99df4b2bcddfc9aa118720c1d0addb8989984d8d 100644 (file)
@@ -92,6 +92,7 @@
     "cookie解密私钥": "private.pem",
     "扫码登录-help": "当扫码登陆设置为true时,每次启动会检查,若失败则会要求登录",
     "扫码登录": true,
+    "扫码登录端口": 0,
     "扫码登录自动打开标签页": false,
     "网络中断不退出": true,
     "http代理地址-help":"例http://127.0.0.1:38223 为空时不使用",