mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-06-07 01:38:21 +00:00
update changelog, do some tiny adjustment
This commit is contained in:
parent
531f4d0421
commit
130610fed6
@ -1,3 +1,9 @@
|
|||||||
|
31 July: AnyProxy 3.7.3:
|
||||||
|
|
||||||
|
* show lastest 100 records when visit the web ui
|
||||||
|
* save map-local config file to local file
|
||||||
|
* show an indicator when filter or map-local is in use
|
||||||
|
|
||||||
31 July: AnyProxy 3.7.2:
|
31 July: AnyProxy 3.7.2:
|
||||||
|
|
||||||
* bugfix for issue #29
|
* bugfix for issue #29
|
||||||
|
@ -47,7 +47,8 @@ function resToMsg(msg,cb){
|
|||||||
//config.port
|
//config.port
|
||||||
function wsServer(config){
|
function wsServer(config){
|
||||||
//web socket interface
|
//web socket interface
|
||||||
var wss = new WebSocketServer({port: config.port});
|
var self = this,
|
||||||
|
wss = new WebSocketServer({port: config.port});
|
||||||
wss.broadcast = function(data) {
|
wss.broadcast = function(data) {
|
||||||
var key = data.id;
|
var key = data.id;
|
||||||
if(typeof data == "object"){
|
if(typeof data == "object"){
|
||||||
@ -86,9 +87,12 @@ function wsServer(config){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding
|
self.wss = wss;
|
||||||
|
}
|
||||||
return wss;
|
|
||||||
|
wsServer.prototype.closeAll = function(){
|
||||||
|
var self = this;
|
||||||
|
self.wss.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = wsServer;
|
module.exports = wsServer;
|
5
proxy.js
5
proxy.js
@ -64,7 +64,8 @@ function proxyServer(option){
|
|||||||
proxyConfigPort = option.webConfigPort || DEFAULT_CONFIG_PORT, //port to ui config server
|
proxyConfigPort = option.webConfigPort || DEFAULT_CONFIG_PORT, //port to ui config server
|
||||||
disableWebInterface = !!option.disableWebInterface,
|
disableWebInterface = !!option.disableWebInterface,
|
||||||
ifSilent = !!option.silent,
|
ifSilent = !!option.silent,
|
||||||
webServerInstance;
|
webServerInstance,
|
||||||
|
ws;
|
||||||
|
|
||||||
if(ifSilent){
|
if(ifSilent){
|
||||||
logUtil.setPrintStatus(false);
|
logUtil.setPrintStatus(false);
|
||||||
@ -130,7 +131,7 @@ function proxyServer(option){
|
|||||||
|
|
||||||
//start web socket service
|
//start web socket service
|
||||||
function(callback){
|
function(callback){
|
||||||
var ws = new wsServer({port : socketPort});
|
ws = new wsServer({port : socketPort});
|
||||||
callback(null)
|
callback(null)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ function util_merge(left,right){
|
|||||||
(function(){
|
(function(){
|
||||||
try{
|
try{
|
||||||
var ws = window.ws = new Anyproxy_wsUtil({
|
var ws = window.ws = new Anyproxy_wsUtil({
|
||||||
baseUrl : document.getElementById("baseUrl").value,
|
baseUrl : document.getElementById("baseUrl").value,
|
||||||
port : document.getElementById("socketPort").value,
|
port : document.getElementById("socketPort").value,
|
||||||
onOpen : function(){
|
onOpen : function(){
|
||||||
eventCenter.dispatchEvent("wsOpen");
|
eventCenter.dispatchEvent("wsOpen");
|
||||||
},
|
},
|
||||||
|
@ -26,46 +26,50 @@ function anyproxy_wsUtil(config){
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var baseUrl = config.baseUrl || "127.0.0.1",
|
var baseUrl = config.baseUrl || "127.0.0.1",
|
||||||
socketPort = config.port || 8003;
|
socketPort = config.port || 8003,
|
||||||
|
dataSocket;
|
||||||
|
|
||||||
var dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
|
function initSocket(){
|
||||||
|
self.bodyCbMap = {};
|
||||||
|
dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
|
||||||
|
dataSocket.onmessage = function(event){
|
||||||
|
config.onGetData && config.onGetData.call(self,event.data);
|
||||||
|
|
||||||
self.bodyCbMap = {};
|
try{
|
||||||
dataSocket.onmessage = function(event){
|
var data = JSON.parse(event.data),
|
||||||
config.onGetData && config.onGetData.call(self,event.data);
|
type = data.type,
|
||||||
|
content = data.content,
|
||||||
|
reqRef = data.reqRef;
|
||||||
|
}catch(e){
|
||||||
|
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
if(type == "update"){
|
||||||
var data = JSON.parse(event.data),
|
config.onGetUpdate && config.onGetUpdate.call(self, content);
|
||||||
type = data.type,
|
|
||||||
content = data.content,
|
|
||||||
reqRef = data.reqRef;
|
|
||||||
}catch(e){
|
|
||||||
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type == "update"){
|
}else if(type == "body"){
|
||||||
config.onGetUpdate && config.onGetUpdate.call(self, content);
|
config.onGetBody && config.onGetBody.call(self, content, reqRef);
|
||||||
|
|
||||||
}else if(type == "body"){
|
if(data.reqRef && self.bodyCbMap[reqRef]){
|
||||||
config.onGetBody && config.onGetBody.call(self, content, reqRef);
|
self.bodyCbMap[reqRef].call(self,content);
|
||||||
|
}
|
||||||
if(data.reqRef && self.bodyCbMap[reqRef]){
|
|
||||||
self.bodyCbMap[reqRef].call(self,content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataSocket.onopen = function(e){
|
||||||
|
config.onOpen && config.onOpen.call(self,e);
|
||||||
|
}
|
||||||
|
dataSocket.onclose = function(e){
|
||||||
|
config.onClose && config.onClose.call(self,e);
|
||||||
|
}
|
||||||
|
dataSocket.onerror = function(e){
|
||||||
|
config.onError && config.onError.call(self,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.dataSocket = dataSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSocket.onopen = function(e){
|
initSocket();
|
||||||
config.onOpen && config.onOpen.call(self,e);
|
|
||||||
}
|
|
||||||
dataSocket.onclose = function(e){
|
|
||||||
config.onClose && config.onClose.call(self,e);
|
|
||||||
}
|
|
||||||
dataSocket.onerror = function(e){
|
|
||||||
config.onError && config.onError.call(self,e);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.dataSocket = dataSocket;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
anyproxy_wsUtil.prototype.send = function(data){
|
anyproxy_wsUtil.prototype.send = function(data){
|
||||||
|
70
web/page.js
70
web/page.js
@ -81,8 +81,8 @@
|
|||||||
(function(){
|
(function(){
|
||||||
try{
|
try{
|
||||||
var ws = window.ws = new Anyproxy_wsUtil({
|
var ws = window.ws = new Anyproxy_wsUtil({
|
||||||
baseUrl : document.getElementById("baseUrl").value,
|
baseUrl : document.getElementById("baseUrl").value,
|
||||||
port : document.getElementById("socketPort").value,
|
port : document.getElementById("socketPort").value,
|
||||||
onOpen : function(){
|
onOpen : function(){
|
||||||
eventCenter.dispatchEvent("wsOpen");
|
eventCenter.dispatchEvent("wsOpen");
|
||||||
},
|
},
|
||||||
@ -436,46 +436,50 @@
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var baseUrl = config.baseUrl || "127.0.0.1",
|
var baseUrl = config.baseUrl || "127.0.0.1",
|
||||||
socketPort = config.port || 8003;
|
socketPort = config.port || 8003,
|
||||||
|
dataSocket;
|
||||||
|
|
||||||
var dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
|
function initSocket(){
|
||||||
|
self.bodyCbMap = {};
|
||||||
|
dataSocket = new WebSocket("ws://" + baseUrl + ":" + socketPort);
|
||||||
|
dataSocket.onmessage = function(event){
|
||||||
|
config.onGetData && config.onGetData.call(self,event.data);
|
||||||
|
|
||||||
self.bodyCbMap = {};
|
try{
|
||||||
dataSocket.onmessage = function(event){
|
var data = JSON.parse(event.data),
|
||||||
config.onGetData && config.onGetData.call(self,event.data);
|
type = data.type,
|
||||||
|
content = data.content,
|
||||||
|
reqRef = data.reqRef;
|
||||||
|
}catch(e){
|
||||||
|
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
if(type == "update"){
|
||||||
var data = JSON.parse(event.data),
|
config.onGetUpdate && config.onGetUpdate.call(self, content);
|
||||||
type = data.type,
|
|
||||||
content = data.content,
|
|
||||||
reqRef = data.reqRef;
|
|
||||||
}catch(e){
|
|
||||||
config.onError && config.onError.call(self, new Error("failed to parse socket data - " + e.toString()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type == "update"){
|
}else if(type == "body"){
|
||||||
config.onGetUpdate && config.onGetUpdate.call(self, content);
|
config.onGetBody && config.onGetBody.call(self, content, reqRef);
|
||||||
|
|
||||||
}else if(type == "body"){
|
if(data.reqRef && self.bodyCbMap[reqRef]){
|
||||||
config.onGetBody && config.onGetBody.call(self, content, reqRef);
|
self.bodyCbMap[reqRef].call(self,content);
|
||||||
|
}
|
||||||
if(data.reqRef && self.bodyCbMap[reqRef]){
|
|
||||||
self.bodyCbMap[reqRef].call(self,content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataSocket.onopen = function(e){
|
||||||
|
config.onOpen && config.onOpen.call(self,e);
|
||||||
|
}
|
||||||
|
dataSocket.onclose = function(e){
|
||||||
|
config.onClose && config.onClose.call(self,e);
|
||||||
|
}
|
||||||
|
dataSocket.onerror = function(e){
|
||||||
|
config.onError && config.onError.call(self,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.dataSocket = dataSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSocket.onopen = function(e){
|
initSocket();
|
||||||
config.onOpen && config.onOpen.call(self,e);
|
|
||||||
}
|
|
||||||
dataSocket.onclose = function(e){
|
|
||||||
config.onClose && config.onClose.call(self,e);
|
|
||||||
}
|
|
||||||
dataSocket.onerror = function(e){
|
|
||||||
config.onError && config.onError.call(self,e);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.dataSocket = dataSocket;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
anyproxy_wsUtil.prototype.send = function(data){
|
anyproxy_wsUtil.prototype.send = function(data){
|
||||||
|
@ -35,8 +35,8 @@ function util_merge(left,right){
|
|||||||
(function(){
|
(function(){
|
||||||
try{
|
try{
|
||||||
var ws = window.ws = new Anyproxy_wsUtil({
|
var ws = window.ws = new Anyproxy_wsUtil({
|
||||||
baseUrl : document.getElementById("baseUrl").value,
|
baseUrl : document.getElementById("baseUrl").value,
|
||||||
port : document.getElementById("socketPort").value,
|
port : document.getElementById("socketPort").value,
|
||||||
onOpen : function(){
|
onOpen : function(){
|
||||||
eventCenter.dispatchEvent("wsOpen");
|
eventCenter.dispatchEvent("wsOpen");
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user