Skip to content

Instantly share code, notes, and snippets.

View HJianBo's full-sized avatar
🛹
Jumping into the Rust universe

JianBo He HJianBo

🛹
Jumping into the Rust universe
  • EMQ Technologies
  • Mars
View GitHub Profile
@HJianBo
HJianBo / erl
Created November 16, 2022 09:32
EMQX 5.0: Generate lots of clients
%% Generate a lot of clients for emqx 5.0
-module(emqx_clients_gen).
-compile(export_all).
-compile(nowarn_export_all).
-define(LOG(Fmt, Args), io:format(Fmt, Args)).
%%--------------------------------------------------------------------
%% APIs
@HJianBo
HJianBo / erl
Created June 12, 2020 07:33 — forked from bokner/erl
debug erlang nif code with lldb
#!/bin/sh
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 1996-2012. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
@HJianBo
HJianBo / README.md
Created July 25, 2019 08:34 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@HJianBo
HJianBo / gist:d29a944f1407609bfda218b2ead17257
Last active July 11, 2019 01:24
Add a temporary route table for Macos
sudo route -n add -net 132.246.0.0 -netmask 255.255.0.0 192.168.7.1

EMQ X 消息服务器 Nginx 反向代理

前言

很多使用 EMQ X 消息服务器的童鞋,会发现随着业务量的增长会考虑到 EMQ X 节点的扩容,多节点之后,如果节点前没有挂载代理,就需要在客户端指定连接哪台 EMQ X 节点,如果其中一台节点升级,还需要在客户端重新做设置,但如果在集群节点挂载反向代理,就可以通过反向代理将连接分配到另外节点上,从而避免在客户端的更改和重新部署。So,今天 EMQ君就聊聊 Nginx 反向代理的事吧!

Nginx安装

依赖安装

@HJianBo
HJianBo / ss.md
Created January 30, 2019 08:46
Shadowsocks original protocol

The shadowsocks protocol is very similar to SOCKS5 but encrypted and simpler.

Below is the structure of a shadowsocks request (sent from client-side), which is identical for both TCP and UDP connections before encrypted (or after decrypted).

+--------------+---------------------+------------------+----------+
| Address Type | Destination Address | Destination Port |   Data   |
+--------------+---------------------+------------------+----------+
|      1       |       Variable      |         2        | Variable |
+--------------+---------------------+------------------+----------+
@HJianBo
HJianBo / utils.erl
Created January 19, 2018 01:58
Erlang Utils Functions
binmstime() ->
%% The time is EMQ server time
{Year, Mon, Day} = date(),
{Hour, Min, Sec} = time(),
{_, _, MicroSecs} = erlang:timestamp(),
list_to_binary(
lists:flatten(
io_lib:format("~2..0w~2..0w~2..0w~2..0w~2..0w~2..0w~3..0w", [Year,Mon,Day,Hour,Min,Sec,trunc(MicroSecs/1000)]))).
@HJianBo
HJianBo / LC_CTYPE.txt
Created November 7, 2017 02:02 — forked from jampajeen/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@HJianBo
HJianBo / Makefile
Created June 28, 2017 04:12
Rebar3-Makefile
REBAR3_URL=https://s3.amazonaws.com/rebar3/rebar3
ifeq ($(wildcard rebar3),rebar3)
REBAR3 = $(CURDIR)/rebar3
endif
REBAR3 ?= $(shell test -e `which rebar3` 2>/dev/null && which rebar3 || echo "./rebar3")
ifeq ($(REBAR3),)
REBAR3 = $(CURDIR)/rebar3