Contents

V2Ray receives Google FCM push

OnePlus, who came back from the maintenance point, had traces of the years on his face, and his body was not as good as day by day. Turn on the battery usage, everyone consumes power except the mobile phone screen Google service is a super power-consuming universe invincible spinning explosion garbage mobile phone QQ that you want to delete but cannot delete.

Green guard here! Drag me out!

All right. Now comes the problem. How to receive news?

We all know that there are two solutions for third-party QQ push, one is < gt r = “5”/> that is said to support the Nougat notification feature and use Google Firebase to push messages, and the other is to use the old version of GCM but support Huawei, Xiaomi, etc. Domestic push SDK < gt r = “6”/> (This project doesn’t even have a README?!)

Torn for a second~~ As a face control, of course, the interface is beautiful~~!

Then the problem arises again. I can’t have a Q and still hang a ladder all day long, right? - If I want to solve this, there is another advantage, other software that uses FCM Push can benefit together, and life in Qng will be very easy.

The traditional way of thinking in online tutorials will tell you, install a haproxy, install a nginx, you have to have a foreign VPS, Barabaraba… But there is no need to do so much for a QQ, and a good line The VPS is really expensive. Since my machines are all domestic and have records, the cost of use is lower. So it is probably the best choice to set up a MojoQQ service in China and let it act as a reverse proxy for both the FCM server level and the Android FCM client.

Program overview

Not long ago, I accidentally heard about a niche patriotic software V2Ray, because I have a ladder and it has been useless, and the configuration is too complicated. Taking a closer look at the documentation, the decoupling of inbound and outbound configurations gives it a lot of flexibility, and it can access ss as an outbound terminal, which simply cannot be more suitable.

Why? SS’s server level program is * rumored * to have been recognized and banned by major hosting providers. And most importantly, I just want to run a binary on the server to do it - reverse generation, routing, and going abroad through SS. Mojo itself has to rely on a lot of people. I don’t want to be more troublesome. I’m going to vomit about operation and maintenance.

Therefore, the solution after using V2Ray is simplified to:

  • Install V2Ray with one click
  • Configuration file glued on
  • Write a line hosts
  • Install FCM-For-Mojo server level with one click
  • Install the client side on the phone
  • Write a line of hosts on your phone

This is very simple.

After the middleman checks the document, it is probably determined that the host that needs to be connected to get through the FCM.

Communication endpoint

I can’t write demos, so I found a < gt r = “7”/> in the Play Store. We can see that its routine is roughly:

  • Register this client side with the FCM service via < gt r = “8”/>
  • Test the connection to < gt r = “9”/> (i.e. application backend), request the service to push the message through FCM
    • This server address of course varies with the application
    • It took me a long time to realize… the appspot was also walled…
  • During this process, Play Services continuously accepts push messages over the XMPP protocol by initiating a long connection to < gt r = “10”/> or < gt r = “11”/>.
  • The application backend sends the request to < gt r = “12”/> push message via FCM [^ fcm].

Server configuration

V2Ray

First download v2ray. You can download it in the release or use the official linux one-click installation script.

bash <(curl -L -s https://install.direct/go.sh)

Then modify the configuration file < gt r = “13”/> as follows. Mac system strongly recommends < gt r = “14”/>! JSON editing artifact!

{
  "log":
  {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "debug"
  },
  "inbound":
  {
    "port": 443,
    "protocol": "dokodemo-door",
    "settings":
    {
      "address": "android.l.google.com",
      "network": "tcp",
      "port": 443
    }
  },
  "inboundDetour":
  [
    {
      "protocol": "dokodemo-door",
      "tag": "xmpp",
      "port": "5228",
      "settings":
      {
        "address": "mobile-gtalk.l.google.com",
        "network": "tcp",
        "port": 5228
      }
    }
  ],
  "outbound":
  {
    "protocol": "shadowsocks",
    "settings":
    {
      "servers":
      [
        {
          "address": "SS_ADDR",
          "port": SS_PORT_INT,
          "method": "SS_ENC_METHOD",
          "password": "SS_PWD"
        }
      ]
    }
  }
}

The configuration file itself has explained itself very clearly. As for complete parameters and advanced functions, including access control, forwarding rules, transparent proxies, etc., refer to the official document [^ v2ray] to discover by yourself.

Inbound protocol < gt r = “15”/> “arbitrary gate” protocol can either do port forwarding (that is, reverse proxy) or change parameters to make transparent proxy similar to < gt r = “16”/>. The forwarded address here only needs to be a Google IP. After all, Google has its own load balance. As long as the Host is correct, it will be connected to the correct server. But this is also a limitation of v2ray. SNIProxy is required to do more complex forwarding on port 443.

Port 5228 in < gt r = “17”/> is the port used for client side push. The port 443 and port 5228 here remain unchanged, so we can set hosts directly on the mobile phone, and v2 will automatically forward the corresponding port to the corresponding host through ss. Repeat, if you want to use port 443 to deploy other services, please use other services such as nginx, SNIProxy, etc. * offload yourself *!

FCM-For-mojo

According to the official tutorial [^ ffm] and mojo tutorial [^ mojo], just copy and paste, if there is no error, a server level will be successfully started and the log will be printed.

SERVER_ZIP=https://github.com/RikkaApps/FCM-for-Mojo/releases/download/v0.5.1/server.zip
curl http://share-10066126.cos.myqcloud.com/cpanm.pl|perl - Mojo::Webqq
mkdir ffm && cd ffm
wget $SERVER_ZIP
mv config.example.js config.js
unzip server.zip && cd node
npm install && cd ..
npm install -g pm2
sudo echo "127.0.0.1 fcm.googleapis.com" >> /etc/hosts
pm2 start node/index.js --name 'mojo'
pm2 logs mojo

Pm2 is similar to python’s supervisor. Directly < gt r = “18”/> Ctrl < gt r = “19 “/> - < gt r =” 20 “/> C < gt r =” 21 “/> Exit and it will run in the background.

Scan code to log in

Open the link and scan the code to log in according to the prompt in the server level log. This framework can only do so based on SmartQQ.

If the image bed hangs, just open the file it prompts on your own machine.

scp vps.yours.com:/tmp/mojo_webqq_qrcode_ffm.png /tmp
open /tmp/mojo_webqq_qrcode_ffm.png  # for mac

Client side configuration

Only for Android.~~ Bullshit where did other phones come from FCM~~

Download the client side of ffm from the official < gt r = “22”/>. Follow the prompts to configure.

Then use software such as < gt r = “25”/> to set hosts, and point < gt r = “23”/> and < gt r = “24”/> to the server IP. Go Hosts is not recommended here. The developer character is extremely poor.