Skip to content

Commit

Permalink
omega_launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
CMA2401PT committed Jul 26, 2022
1 parent 9322927 commit 2d41117
Show file tree
Hide file tree
Showing 31 changed files with 1,885 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ sdks/
plantform_specific_interperters
dotcs_plugins

*.tar.gz
*.tar.gz
omega_release/binary
98 changes: 98 additions & 0 deletions omega_release/compressor/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package main

import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
"sync"

"github.com/andybalholm/brotli"
)

func GetFileData(fname string) ([]byte, error) {
fp, err := os.OpenFile(fname, os.O_CREATE|os.O_RDONLY, 0755)
if err != nil {
return nil, err
}
defer fp.Close()
buf, err := ioutil.ReadAll(fp)
if err != nil {
return nil, err
}
return buf, err
}

func WriteFileData(fname string, data []byte) error {
fp, err := os.OpenFile(fname, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
if err != nil {
return err
}
defer fp.Close()
if _, err := fp.Write(data); err != nil {
return err
}
return nil
}

func CompressSingleFile(in, out string) {
var origData []byte
var err error
origData, err = GetFileData(in)
if err != nil || len(origData) == 0 {
panic(fmt.Sprintf("read %v fail", in))
}

buf := bytes.NewBuffer([]byte{})
compressor := brotli.NewWriterLevel(buf, brotli.DefaultCompression)
compressor.Write(origData)
compressor.Close()
newData := buf.Bytes()

if err := WriteFileData(out, newData); err != nil {
panic(err)
}
fmt.Printf("comprerss: %v -> %v compress %.3f\n", in, out, float32(len(newData))/float32(len(origData)))
}

func main() {
inFile := flag.String("in", "", "input")
outFile := flag.String("out", "", "outfile")
flag.Parse()
if strings.Contains(*inFile, ",") {
ins := strings.Split(*inFile, ",")
outs := strings.Split(*outFile, ",")
if len(ins) != len(outs) {
panic(fmt.Errorf("%v!->%v :input/outputs mismatch", ins, outs))
}
var wg sync.WaitGroup
for i := range ins {
wg.Add(1)
in, out := strings.TrimSpace(ins[i]), strings.TrimSpace(outs[i])
go func() {
CompressSingleFile(in, out)
wg.Done()
}()
}
wg.Wait()
fmt.Println("All tasks finished")
} else {
CompressSingleFile(*inFile, *outFile)
}

// var compressedData []byte
// if compressedData, err = GetFileData(*outFile); err != nil {
// panic(err)
// }

// if recoveredData, err := ioutil.ReadAll(brotli.NewReader(bytes.NewReader(compressedData))); err != nil {
// panic(err)
// } else {
// if bytes.Compare(recoveredData, origData) != 0 {
// panic("not same")
// }
// fmt.Println("Success")
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 关于群服互通问题整理
## 前置条件、背景、问题说明
你已经阅读了 群文件的 Omega 教程
你有一个安卓手机、或者 Windows 电脑,且可以正常使用 fb 和 qq(用你打算登录的小号)

我们知道腾讯对账号安全会进行风险控制(下文简称风控)
在安卓手机和电脑上使用 Omega 的群服互通基本不会遇到任何障碍,因为这个设备上**本来就可以正常使用 QQ,因此不会被风控**
但是,无论是云服务器还是面板服代挂,都会被**腾讯风控**(因为那些设备上从没有登录过 QQ),所有群服互通功能无法使用

所以,本文的目的是指导如何利用 Omega 提供的协助绕过 **腾讯风控** 从而在 **云服务器或者面板服上** 正常使用群服互通功能

## 第一步:生成登录文件
上文讲到,在安卓手机和电脑上使用 Omega 的群服互通基本不会遇到任何障碍,因为这个设备上**本来就可以正常使用 QQ,因此不会被风控**

1. 因此,我们需要一部 可以使用 fb 的安卓手机和电脑
2.**群文件的 Omega 教程** 登录 **至少两次****在第二次使用时** 选择启用群服互通,并成功启动 Omega
3. 不出意外,此时在 omega_storage 文件夹下出现了一个名为 "上传这个文件到云服务器以使用云服务器的群服互通.data" 的文件
***(什么?你问我 omega_storage 文件夹在哪?你好好看群文件的 Omega 教程了吗?)***

## 第二步:在云服务器上使用登录文件
1. 在面板服或是云服务器上运行 Omega 一次,注意不要启用群服互通
2. 将上述文件 ("上传这个文件到云服务器以使用云服务器的群服互通.data") 上传到云服务器的 omega_storage 文件夹底下
3. 启动 Omega,此时会询问你是否导入配置,输入 y 导入即可,然后就可以使用群服互通了

## 其他问题
1. Q:提示: cqhttp text file busy
A: 删除 cqhttp 文件即可
2. Q:提示: 打开数据库失败
A: 请在文件管理cqhttp_storage 下删除data文件夹和logs 文件夹
57 changes: 57 additions & 0 deletions omega_release/launcher/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.PHONY: all current
TARGETS:=build/ current current-v8
PACKAGETARGETS:=
ifeq ($(shell uname | grep "Darwin" > /dev/null ; echo $${?}),0)
ifeq ($(shell uname -m | grep -E "iPhone|iPad|iPod" > /dev/null ; echo $${?}),0)
IOS_STRIP=/usr/bin/strip
LIPO=/usr/bin/lipo
LDID=/usr/bin/ldid
TARGETS:=${TARGETS} ios-executable ios-v8-executable ios-lib
else
IOS_STRIP=$(shell xcrun --sdk iphoneos -f strip)
IOS_OBJCOPY=$(shell xcrun --sdk iphoneos -f objcopy)
LDID=ldid2
LIPO=/usr/bin/lipo
TARGETS:=${TARGETS} macos ios-v8-executable ios-executable ios-lib
endif
PACKAGETARGETS:=${PACKAGETARGETS} package/ios
else
IOS_STRIP=true
LDID=$${THEOS}/toolchain/linux/iphone/bin/ldid
LIPO=$${THEOS}/toolchain/linux/iphone/bin/lipo
IOS_OBJCOPY=$${THEOS}/toolchain/linux/iphone/bin/llvm-objcopy
endif

SRCS_GO := $(foreach dir, $(shell find . -type d), $(wildcard $(dir)/*.go $(dir)/*.c))

all: linux macos windows mcsm-linux mcsm-windows android
linux: build/launcher-linux
macos: build/launcher-macos
windows: build/launcher-windows.exe
android: build/launcher-android
mcsm-linux: build/launcher-linux-mcsm
mcsm-windows: build/launcher-windows-mcsm

package: ${PACKAGETARGETS}
release/:
mkdir -p release
build/:
mkdir build
build/launcher-linux: build/ ${SRCS_GO}
CGO_CFLAGS=${CGO_DEF} CGO_ENABLED=1 go build -trimpath -ldflags "-s -w" -o $@
cp build/launcher-linux build/Linux版Omega启动器
build/launcher-linux-mcsm:
CGO_CFLAGS=${CGO_DEF} CGO_ENABLED=1 go build -trimpath -tags="mcsm" -ldflags "-s -w" -o $@
build/launcher-windows-mcsm:
CGO_CFLAGS=${CGO_DEF} CC=/usr/bin/x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -tags="mcsm" -ldflags "-s -w" -o $@
mv $@ build/Windows版MCSM特供Omega启动器.exe
build/launcher-macos: build/ ${SRCS_GO}
CGO_CFLAGS=${CGO_DEF} CC=`pwd`/macos CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o $@
cp $@ build/MacOS版Omega启动器
build/launcher-windows.exe: build/ /usr/bin/x86_64-w64-mingw32-gcc ${SRCS_GO}
CGO_CFLAGS=${CGO_DEF} CC=/usr/bin/x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -ldflags "-s -w" -o $@
mv $@ build/Windows版Omega启动器.exe
build/launcher-android: build/ ${HOME}/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang ${SRCS_GO}
CGO_CFLAGS=${CGO_DEF} CC=${HOME}/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang CXX=${HOME}/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build -trimpath -ldflags "-s -w -extldflags -static-libstdc++" -o $@
clean:
rm -rf build/*
48 changes: 48 additions & 0 deletions omega_release/launcher/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
account:
uin: [QQ账号]
password: [QQ密码]
encrypt: false
status: 0
relogin:
delay: 3
interval: 3
max-times: 0
use-sso-address: true
allow-temp-session: false
heartbeat:
interval: 5
message:
post-format: string
ignore-invalid-cqcode: true
force-fragment: false
fix-url: false
proxy-rewrite: ''
report-self-message: false
remove-reply-at: false
extra-reply-data: false
skip-mime-scan: false
output:
log-level: warn
log-aging: 15
log-force-new: true
log-colorful: true
debug: false
default-middlewares: &default
access-token: ''
filter: ''
rate-limit:
enabled: false
frequency: 1
bucket: 1
database:
leveldb:
enable: true
cache:
image: data/image.db
video: data/video.db
servers:
- ws:
host: 127.0.0.1
port: 6700
middlewares:
<<: *default
12 changes: 12 additions & 0 deletions omega_release/launcher/embed_binary/android.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build android
// +build android

package embed_binary

import (
_ "embed"
)

//go:embed cqhttp-android.brotli
var embedding_cqhttp []byte
var PLANTFORM = Android_arm64
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions omega_release/launcher/embed_binary/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package embed_binary

const (
WINDOWS_x86_64 = "windows_x86_64"
MACOS_x86_64 = "macos_x86_64"
Linux_x86_64 = "linux_x86_64"
Android_arm64 = "android_arm64"
)

func GetCqHttpBinary() []byte {
return embedding_cqhttp
}

func GetPlantform() string {
return PLANTFORM
}
12 changes: 12 additions & 0 deletions omega_release/launcher/embed_binary/linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build linux && !android
// +build linux,!android

package embed_binary

import (
_ "embed"
)

//go:embed cqhttp-linux.brotli
var embedding_cqhttp []byte
var PLANTFORM = Linux_x86_64
12 changes: 12 additions & 0 deletions omega_release/launcher/embed_binary/macos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build darwin
// +build darwin

package embed_binary

import (
_ "embed"
)

//go:embed cqhttp-macos.brotli
var embedding_cqhttp []byte
var PLANTFORM = MACOS_x86_64
12 changes: 12 additions & 0 deletions omega_release/launcher/embed_binary/windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build windows
// +build windows

package embed_binary

import (
_ "embed"
)

//go:embed cqhttp-windows.brotli
var embedding_cqhttp []byte
var PLANTFORM = WINDOWS_x86_64
20 changes: 20 additions & 0 deletions omega_release/launcher/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module omega_launcher

go 1.18

require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/atomicgo/cursor v0.0.1 // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gookit/color v1.5.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/pterm/pterm v0.12.41 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/struCoder/pidusage v0.2.1 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading

0 comments on commit 2d41117

Please sign in to comment.