From 242335a9862887d5bbbf76089db40f4430d32b6e Mon Sep 17 00:00:00 2001 From: SinTod Date: Mon, 7 Feb 2022 18:55:08 +0800 Subject: [PATCH 1/2] add config.yml --- push/gorush-with-mipush/src/.gitignore | 39 ------- .../src/config/testdata/config.yml | 106 ++++++++++++++++++ 2 files changed, 106 insertions(+), 39 deletions(-) delete mode 100644 push/gorush-with-mipush/src/.gitignore create mode 100644 push/gorush-with-mipush/src/config/testdata/config.yml diff --git a/push/gorush-with-mipush/src/.gitignore b/push/gorush-with-mipush/src/.gitignore deleted file mode 100644 index 1fd9c9a..0000000 --- a/push/gorush-with-mipush/src/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof - -gin-bin -key.pem -.DS_Store -gorush/log/*.log -gorush.db -.cover -*.db* -coverage.txt -dist -custom -release -coverage.txt -node_modules -config.yml diff --git a/push/gorush-with-mipush/src/config/testdata/config.yml b/push/gorush-with-mipush/src/config/testdata/config.yml new file mode 100644 index 0000000..f62f7a8 --- /dev/null +++ b/push/gorush-with-mipush/src/config/testdata/config.yml @@ -0,0 +1,106 @@ +core: + enabled: true # enable httpd server + address: "" # ip address to bind (default: any) + shutdown_timeout: 30 # default is 30 second + port: "8088" # ignore this port number if auto_tls is enabled (listen 443). + worker_num: 0 # default worker number is runtime.NumCPU() + queue_num: 0 # default queue number is 8192 + max_notification: 100 + sync: false # set true if you need get error message from fail push notification in API response. + feedback_hook_url: "" # set a hook url if you need get error message asynchronously from fail push notification in API response. + feedback_timeout: 10 # default is 10 second + mode: "release" + ssl: false + cert_path: "cert.pem" + key_path: "key.pem" + cert_base64: "" + key_base64: "" + http_proxy: "" + pid: + enabled: false + path: "gorush.pid" + override: true + auto_tls: + enabled: false # Automatically install TLS certificates from Let's Encrypt. + folder: ".cache" # folder for storing TLS certificates + host: "" # which domains the Let's Encrypt will attempt + +grpc: + enabled: false # enable gRPC server + port: 9000 + +api: + push_uri: "/api/push" + stat_go_uri: "/api/stat/go" + stat_app_uri: "/api/stat/app" + config_uri: "/api/config" + sys_stat_uri: "/sys/stats" + metric_uri: "/metrics" + health_uri: "/healthz" + +android: + enabled: true + apikey: "YOUR_API_KEY" + max_retry: 0 # resend fail notification, default value zero is disabled + +huawei: + enabled: false + appsecret: "YOUR_APP_SECRET" + appid: "YOUR_APP_ID" + max_retry: 0 # resend fail notification, default value zero is disabled +mi: + enabled: true + appsecret: "xxxxxxx" + package: "xxxxxxx" + max_retry: 3 # resend fail notification, default value zero is disabled +queue: + engine: "local" # support "local", "nsq", "nats" and "redis" default value is "local" + nsq: + addr: 127.0.0.1:4150 + topic: gorush + channel: gorush + nats: + addr: 127.0.0.1:4222 + subj: gorush + queue: gorush + redis: + addr: 127.0.0.1:6379 + channel: gorush + size: 1024 + +ios: + enabled: false + key_path: "key.pem" + key_base64: "" # load iOS key from base64 input + key_type: "pem" # could be pem, p12 or p8 type + password: "" # certificate password, default as empty string. + production: false + max_concurrent_pushes: 100 # just for push ios notification + max_retry: 0 # resend fail notification, default value zero is disabled + key_id: "" # KeyID from developer account (Certificates, Identifiers & Profiles -> Keys) + team_id: "" # TeamID from developer account (View Account -> Membership) + +log: + format: "string" # string or json + access_log: "stdout" # stdout: output to console, or define log path like "log/access_log" + access_level: "debug" + error_log: "stderr" # stderr: output to console, or define log path like "log/error_log" + error_level: "error" + hide_token: true + +stat: + engine: "memory" # support memory, redis, boltdb, buntdb or leveldb + redis: + cluster: false + addr: "localhost:6379" # if cluster is true, you may set this to "localhost:6379,localhost:6380,localhost:6381" + password: "" + db: 0 + boltdb: + path: "bolt.db" + bucket: "gorush" + buntdb: + path: "bunt.db" + leveldb: + path: "level.db" + badgerdb: + path: "badger.db" From 9104131c6fcb305dd8fa8567ac07434cc36ffe7e Mon Sep 17 00:00:00 2001 From: SinTod Date: Mon, 7 Feb 2022 19:01:51 +0800 Subject: [PATCH 2/2] modify README.md --- push/gorush-with-mipush/src/README.md | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/push/gorush-with-mipush/src/README.md b/push/gorush-with-mipush/src/README.md index 67ff161..d8dcc61 100644 --- a/push/gorush-with-mipush/src/README.md +++ b/push/gorush-with-mipush/src/README.md @@ -1331,3 +1331,52 @@ Or you can deploy gorush to alternative solution like [netlify functions](https: Copyright 2019 Bo-Yi Wu [@appleboy](https://twitter.com/appleboy). Licensed under the MIT License. + +## gorush with MIPUSH + +### RUN + +```bash +./gorush -c ./config/testdata/config.yml + +``` + +```yaml +#add section +mi: + enabled: true + appsecret: "xxxxxxx" + package: "xxxxxxx" + max_retry: 3 # resend fail notification, default value zero is disabled +``` + +### API case + +```bash +# 单推 or 群推 +curl --location --request POST '127.0.0.1:8088/api/push' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "notifications": [ + { + "tokens": ["ufnjAD7ON0VfYUgZYNeFVId7Q9KXyGYIA2GrOTnE6JLlTmn+c7wR147AYJXcY7rv"], + "platform": 4, + "title":"Hello World MIPUSH!", + "message": "Hello World MIPUSH!" + } + ] +}' +# 全推 +curl --location --request POST '127.0.0.1:8088/api/push' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "notifications": [ + { + "tokens": [], + "platform": 4, + "title":"Hello World MIPUSH!", + "message": "Hello World MIPUSH!" + } + ] +}' +```