to apigo.cc

This commit is contained in:
Star 2024-06-26 12:17:41 +08:00
parent 6b1b9d8c6a
commit 6e6927913b
31 changed files with 66 additions and 68 deletions

View File

@ -1,13 +1,13 @@
package crypt package crypt
import ( import (
"crypto/sha512" "crypto/sha256"
"github.com/ZZMarquis/gm/sm3" "github.com/ZZMarquis/gm/sm3"
"hash" "hash"
) )
func (c *CMCrypt) NewHash() hash.Hash { func (c *CMCrypt) NewHash() hash.Hash {
return sha512.New() return sha256.New()
} }
func (c *GMCrypt) NewHash() hash.Hash { func (c *GMCrypt) NewHash() hash.Hash {
@ -27,4 +27,4 @@ func makeHash(h hash.Hash, data ...[]byte) []byte {
h.Write(b) h.Write(b)
} }
return h.Sum(nil) return h.Sum(nil)
} }

View File

@ -1,8 +1,8 @@
package crypto package crypto
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"apigo.cloud/git/apigo/plugins/crypto/crypt" "apigo.cc/apigo/plugins/crypto/crypt"
"crypto/md5" "crypto/md5"
"crypto/sha1" "crypto/sha1"
"crypto/sha256" "crypto/sha256"
@ -21,7 +21,7 @@ var defaultCryptoLock = sync.RWMutex{}
func init() { func init() {
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/crypto", Id: "apigo.cc/apigo/plugins/crypto",
Name: "加密算法", Name: "加密算法",
ConfigSample: `mode: cm # 指定默认算法集cm-通用算法SHA256、AES、ECDSAgm-国密算法sm3、sm4、sm2`, ConfigSample: `mode: cm # 指定默认算法集cm-通用算法SHA256、AES、ECDSAgm-国密算法sm3、sm4、sm2`,
Init: func(conf map[string]interface{}) { Init: func(conf map[string]interface{}) {

View File

@ -1,7 +1,7 @@
package db package db
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"bytes" "bytes"
_ "embed" _ "embed"
"github.com/ssgo/db" "github.com/ssgo/db"

View File

@ -1,7 +1,7 @@
package db package db
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
_ "embed" _ "embed"
"fmt" "fmt"
"github.com/ssgo/db" "github.com/ssgo/db"

View File

@ -1,5 +1,5 @@
import db from "apigo.cloud/git/apigo/plugins/db" import db from "apigo.cc/apigo/plugins/db"
import redis from "apigo.cloud/git/apigo/plugins/redis" import redis from "apigo.cc/apigo/plugins/redis"
import logger from "logger" import logger from "logger"
/*{{$dao := . -}}*/ /*{{$dao := . -}}*/

View File

@ -1,7 +1,7 @@
package db package db
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"fmt" "fmt"
"github.com/ssgo/db" "github.com/ssgo/db"
"github.com/ssgo/log" "github.com/ssgo/log"
@ -39,7 +39,7 @@ var configSetLock = sync.RWMutex{}
func init() { func init() {
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/db", Id: "apigo.cc/apigo/plugins/db",
Name: "数据库操作", Name: "数据库操作",
ConfigSample: `default: mysql://root:<**encrypted_password**>@127.0.0.1:3306/1?maxIdles=0&maxLifeTime=0&maxOpens=0&logSlow=1s # set default db connection pool, used by db.xxx ConfigSample: `default: mysql://root:<**encrypted_password**>@127.0.0.1:3306/1?maxIdles=0&maxLifeTime=0&maxOpens=0&logSlow=1s # set default db connection pool, used by db.xxx
configs: configs:

View File

@ -1,7 +1,7 @@
package file package file
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"bufio" "bufio"
"errors" "errors"
"github.com/ssgo/u" "github.com/ssgo/u"
@ -36,7 +36,7 @@ type FileInfo struct {
func init() { func init() {
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/file", Id: "apigo.cc/apigo/plugins/file",
Name: "文件操作", Name: "文件操作",
ConfigSample: `allowPaths: # 允许操作的文件路径 ConfigSample: `allowPaths: # 允许操作的文件路径
- / - /

4
go.mod
View File

@ -1,9 +1,9 @@
module apigo.cloud/git/apigo/plugins module apigo.cc/apigo/plugins
go 1.17 go 1.17
require ( require (
apigo.cloud/git/apigo/plugin v1.0.1 apigo.cc/apigo/plugin v1.0.2
github.com/ZZMarquis/gm v1.3.2 github.com/ZZMarquis/gm v1.3.2
github.com/emmansun/gmsm v0.21.1 github.com/emmansun/gmsm v0.21.1
github.com/gorilla/websocket v1.5.1 github.com/gorilla/websocket v1.5.1

View File

@ -1,7 +1,7 @@
package http package http
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"errors" "errors"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/ssgo/httpclient" "github.com/ssgo/httpclient"
@ -26,7 +26,7 @@ var defaultClient = Client{
func init() { func init() {
defaultClient.pool.EnableRedirect() defaultClient.pool.EnableRedirect()
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/http", Id: "apigo.cc/apigo/plugins/http",
Name: "HTTP客户端", Name: "HTTP客户端",
Objects: map[string]interface{}{ Objects: map[string]interface{}{
"new": NewHTTP, "new": NewHTTP,

View File

@ -1,7 +1,7 @@
package redis package redis
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"encoding/json" "encoding/json"
"github.com/ssgo/log" "github.com/ssgo/log"
"github.com/ssgo/redis" "github.com/ssgo/redis"
@ -18,7 +18,7 @@ var configSetLock = sync.RWMutex{}
func init() { func init() {
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/redis", Id: "apigo.cc/apigo/plugins/redis",
Name: "Redis客户端", Name: "Redis客户端",
ConfigSample: `default: redis://:<**encrypted_password**>@127.0.0.1:6379/1?timeout=10s&logSlow=100ms # set default redis connection pool, used by redis.xxx ConfigSample: `default: redis://:<**encrypted_password**>@127.0.0.1:6379/1?timeout=10s&logSlow=100ms # set default redis connection pool, used by redis.xxx
configs: configs:

View File

@ -1,7 +1,7 @@
package runtime package runtime
import ( import (
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
"github.com/ssgo/u" "github.com/ssgo/u"
"runtime" "runtime"
"time" "time"
@ -9,7 +9,7 @@ import (
func init() { func init() {
plugin.Register(plugin.Plugin{ plugin.Register(plugin.Plugin{
Id: "apigo.cloud/git/apigo/plugins/runtime", Id: "apigo.cc/apigo/plugins/runtime",
Name: "运行时支持", Name: "运行时支持",
Objects: map[string]interface{}{ Objects: map[string]interface{}{
// sleep 程序等待指定时间 // sleep 程序等待指定时间

View File

@ -1,8 +1,8 @@
package tests package tests
import ( import (
"apigo.cloud/git/apigo/gojs" "apigo.cc/apigo/gojs"
_ "apigo.cloud/git/apigo/plugins/crypto" _ "apigo.cc/apigo/plugins/crypto"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"

View File

@ -1,4 +1,4 @@
import crypto from "apigo.cloud/git/apigo/plugins/crypto" import crypto from "apigo.cc/apigo/plugins/crypto"
let key = "?GQ$0K0GgLdO=f+~L68PLm$uhKr4'=tV" let key = "?GQ$0K0GgLdO=f+~L68PLm$uhKr4'=tV"
let iv = new Uint8Array([86,70,115,55,64,115,75,54,49,99,106,94,102,63,72,90]) let iv = new Uint8Array([86,70,115,55,64,115,75,54,49,99,106,94,102,63,72,90])

View File

@ -1,4 +1,4 @@
import crypto from "apigo.cloud/git/apigo/plugins/crypto" import crypto from "apigo.cc/apigo/plugins/crypto"
let [priKey, pubKey] = crypto.ecdsa.genKey() let [priKey, pubKey] = crypto.ecdsa.genKey()
let s1 = crypto.ecdsa.sign('hello 123', priKey) let s1 = crypto.ecdsa.sign('hello 123', priKey)

View File

@ -1,4 +1,4 @@
import crypto from "apigo.cloud/git/apigo/plugins/crypto" import crypto from "apigo.cc/apigo/plugins/crypto"
if(crypto.md5('hello 123') !== '1bb45824de71b2f6476d800f427cb2ab') throw new Error('md5 error') if(crypto.md5('hello 123') !== '1bb45824de71b2f6476d800f427cb2ab') throw new Error('md5 error')
if(crypto.sm3('hello 123') !== '4e1f46e2350250d20df71c360852751c8aed29753e6058969602cea8639f7737') throw new Error('sm3 error') if(crypto.sm3('hello 123') !== '4e1f46e2350250d20df71c360852751c8aed29753e6058969602cea8639f7737') throw new Error('sm3 error')

View File

@ -1,4 +1,4 @@
import crypto from "apigo.cloud/git/apigo/plugins/crypto" import crypto from "apigo.cc/apigo/plugins/crypto"
let [priKey, pubKey] = crypto.sm2.genKey() let [priKey, pubKey] = crypto.sm2.genKey()
let s1 = crypto.sm2.sign('hello 123', priKey) let s1 = crypto.sm2.sign('hello 123', priKey)

View File

@ -1,4 +1,4 @@
import crypto from "apigo.cloud/git/apigo/plugins/crypto" import crypto from "apigo.cc/apigo/plugins/crypto"
let key = "?GQ$0K0GgLdO=f+~L68PLm$uhKr4'=tV" let key = "?GQ$0K0GgLdO=f+~L68PLm$uhKr4'=tV"
let iv = new Uint8Array([86,70,115,55,64,115,75,54,49,99,106,94,102,63,72,90]) let iv = new Uint8Array([86,70,115,55,64,115,75,54,49,99,106,94,102,63,72,90])

View File

@ -1,11 +1,11 @@
package tests package tests
import ( import (
"apigo.cloud/git/apigo/gojs" "apigo.cc/apigo/gojs"
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
_ "apigo.cloud/git/apigo/plugins/db" _ "apigo.cc/apigo/plugins/db"
_ "apigo.cloud/git/apigo/plugins/file" _ "apigo.cc/apigo/plugins/file"
_ "apigo.cloud/git/apigo/plugins/redis" _ "apigo.cc/apigo/plugins/redis"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/ssgo/u" "github.com/ssgo/u"
"os" "os"
@ -17,7 +17,7 @@ func T1estSql(t *testing.T) {
defer rt.Close() defer rt.Close()
gojs.SetPluginsConfig(map[string]plugin.Config{ gojs.SetPluginsConfig(map[string]plugin.Config{
"apigo.cloud/git/apigo/plugins/db": { "apigo.cc/apigo/plugins/db": {
"default": "sqlite3://Test.db", "default": "sqlite3://Test.db",
}, },
}) })
@ -53,10 +53,10 @@ func TestDao(t *testing.T) {
defer rdServer.Close() defer rdServer.Close()
gojs.SetPluginsConfig(map[string]plugin.Config{ gojs.SetPluginsConfig(map[string]plugin.Config{
"apigo.cloud/git/apigo/plugins/db": { "apigo.cc/apigo/plugins/db": {
"default": "sqlite3://Test.db", "default": "sqlite3://Test.db",
}, },
"apigo.cloud/git/apigo/plugins/redis": { "apigo.cc/apigo/plugins/redis": {
"default": "redis://localhost:16379", "default": "redis://localhost:16379",
}, },
}) })

View File

@ -1,5 +1,5 @@
import db from "apigo.cloud/git/apigo/plugins/db" import db from "apigo.cc/apigo/plugins/db"
import file from "apigo.cloud/git/apigo/plugins/file" import file from "apigo.cc/apigo/plugins/file"
let testDBDesc = file.loadYaml('./TestDB.yml') let testDBDesc = file.loadYaml('./TestDB.yml')
db.make(testDBDesc) db.make(testDBDesc)

View File

@ -1,5 +1,5 @@
import {TestDao} from "./TestDao" import {TestDao} from "./TestDao"
import file from "apigo.cloud/git/apigo/plugins/file" import file from "apigo.cc/apigo/plugins/file"
function testInsert() { function testInsert() {
let dao = new TestDao() let dao = new TestDao()

View File

@ -1,5 +1,5 @@
import db from "apigo.cloud/git/apigo/plugins/db" import db from "apigo.cc/apigo/plugins/db"
import file from "apigo.cloud/git/apigo/plugins/file" import file from "apigo.cc/apigo/plugins/file"
db.make(file.loadYaml('./TestDB.yml')) db.make(file.loadYaml('./TestDB.yml'))

View File

@ -1,9 +1,9 @@
package tests package tests
import ( import (
"apigo.cloud/git/apigo/gojs" "apigo.cc/apigo/gojs"
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
_ "apigo.cloud/git/apigo/plugins/file" _ "apigo.cc/apigo/plugins/file"
"testing" "testing"
) )
@ -12,7 +12,7 @@ func TestFile(t *testing.T) {
defer rt.Close() defer rt.Close()
gojs.SetPluginsConfig(map[string]plugin.Config{ gojs.SetPluginsConfig(map[string]plugin.Config{
"apigo.cloud/git/apigo/plugins/file": { "apigo.cc/apigo/plugins/file": {
"allowPaths": []string{ "allowPaths": []string{
"testData", "testData",
}, },

View File

@ -1,4 +1,4 @@
import file from "apigo.cloud/git/apigo/plugins/file" import file from "apigo.cc/apigo/plugins/file"
try { try {
file.write('testData/aaa.txt', '123') file.write('testData/aaa.txt', '123')

View File

@ -1,13 +1,11 @@
module tests module tests
go 1.22 go 1.17
toolchain go1.22.1
require ( require (
apigo.cloud/git/apigo/gojs v0.0.8 apigo.cc/apigo/gojs v0.0.9
apigo.cloud/git/apigo/plugin v1.0.1 apigo.cc/apigo/plugin v1.0.2
apigo.cloud/git/apigo/plugins v0.0.0 apigo.cc/apigo/plugins v0.0.0
github.com/mattn/go-sqlite3 v1.14.18 github.com/mattn/go-sqlite3 v1.14.18
github.com/ssgo/s v1.7.5 github.com/ssgo/s v1.7.5
github.com/ssgo/u v1.7.5 github.com/ssgo/u v1.7.5
@ -15,7 +13,7 @@ require (
) )
require ( require (
apigo.cloud/git/apigo/qjs v0.0.1 // indirect apigo.cc/apigo/qjs v0.0.3 // indirect
github.com/ZZMarquis/gm v1.3.2 // indirect github.com/ZZMarquis/gm v1.3.2 // indirect
github.com/emmansun/gmsm v0.21.1 // indirect github.com/emmansun/gmsm v0.21.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ole/go-ole v1.2.6 // indirect
@ -47,4 +45,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace apigo.cloud/git/apigo/plugins v0.0.0 => ../ replace apigo.cc/apigo/plugins v0.0.0 => ../

View File

@ -1,8 +1,8 @@
package tests package tests
import ( import (
"apigo.cloud/git/apigo/gojs" "apigo.cc/apigo/gojs"
_ "apigo.cloud/git/apigo/plugins/http" _ "apigo.cc/apigo/plugins/http"
"github.com/ssgo/s" "github.com/ssgo/s"
"os" "os"
"path/filepath" "path/filepath"
@ -50,14 +50,14 @@ func TestH2C(t *testing.T) {
rt.JsCtx.Globals().Set("server", rt.JsCtx.String(as.Addr)) rt.JsCtx.Globals().Set("server", rt.JsCtx.String(as.Addr))
_, err := rt.Run(` _, err := rt.Run(`
import http from "apigo.cloud/git/apigo/plugins/http" import http from "apigo.cc/apigo/plugins/http"
http.get('http://'+server+'/echo?aaa=111') http.get('http://'+server+'/echo?aaa=111')
`) `)
//fmt.Println(u.BMagenta(err)) //fmt.Println(u.BMagenta(err))
Test(t, "get for h2c", err != nil && strings.Contains(err.Error(), "transport connection broken")) Test(t, "get for h2c", err != nil && strings.Contains(err.Error(), "transport connection broken"))
r, err := rt.Run(` r, err := rt.Run(`
import http from "apigo.cloud/git/apigo/plugins/http" import http from "apigo.cc/apigo/plugins/http"
let c = http.newH2C(10) let c = http.newH2C(10)
r = c.post('http://'+server+'/echo', {aaa:111}) r = c.post('http://'+server+'/echo', {aaa:111})
if(r.data.aaa != 111) throw new Error('aaa is '+r.data.aaa+' not 111') if(r.data.aaa != 111) throw new Error('aaa is '+r.data.aaa+' not 111')

View File

@ -1,4 +1,4 @@
import http from "apigo.cloud/git/apigo/plugins/http" import http from "apigo.cc/apigo/plugins/http"
let serv = startTestServer('10803') let serv = startTestServer('10803')
let r = http.get('http://127.0.0.1:10803/echo?aaa=111') let r = http.get('http://127.0.0.1:10803/echo?aaa=111')

View File

@ -1,4 +1,4 @@
import http from "apigo.cloud/git/apigo/plugins/http" import http from "apigo.cc/apigo/plugins/http"
let serv = startTestServer('10803') let serv = startTestServer('10803')
let r = http.get('http://127.0.0.1:10803/jump') let r = http.get('http://127.0.0.1:10803/jump')

View File

@ -1,4 +1,4 @@
import http from "apigo.cloud/git/apigo/plugins/http" import http from "apigo.cc/apigo/plugins/http"
let serv = startTestServer('10803') let serv = startTestServer('10803')
let r = http.post('http://127.0.0.1:10803/echo', {aaa:111}) let r = http.post('http://127.0.0.1:10803/echo', {aaa:111})

View File

@ -1,9 +1,9 @@
package tests package tests
import ( import (
"apigo.cloud/git/apigo/gojs" "apigo.cc/apigo/gojs"
"apigo.cloud/git/apigo/plugin" "apigo.cc/apigo/plugin"
_ "apigo.cloud/git/apigo/plugins/redis" _ "apigo.cc/apigo/plugins/redis"
"testing" "testing"
) )
@ -12,7 +12,7 @@ func TestRedis(t *testing.T) {
defer rdServer.Close() defer rdServer.Close()
gojs.SetPluginsConfig(map[string]plugin.Config{ gojs.SetPluginsConfig(map[string]plugin.Config{
"apigo.cloud/git/apigo/plugins/redis": { "apigo.cc/apigo/plugins/redis": {
"default": "redis://localhost:16378", "default": "redis://localhost:16378",
"configs": map[string]string{ "configs": map[string]string{
"bak": "redis://localhost:16378/2", "bak": "redis://localhost:16378/2",

View File

@ -1,4 +1,4 @@
import redis from "apigo.cloud/git/apigo/plugins/redis" import redis from "apigo.cc/apigo/plugins/redis"
redis.set('aaa', 111) redis.set('aaa', 111)
let aaa = redis.get('aaa') let aaa = redis.get('aaa')

View File

@ -1,8 +1,8 @@
package util package util
import ( import (
"apigo.cc/apigo/plugin"
"encoding/hex" "encoding/hex"
"apigo.cloud/git/apigo/plugin"
"github.com/ssgo/u" "github.com/ssgo/u"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )