Răsfoiți Sursa

优化代码及增加配置文件

hliang 1 an în urmă
părinte
comite
d816b2bbd9
10 a modificat fișierele cu 412 adăugiri și 2416 ștergeri
  1. 0 1049
      .dockerignore
  2. 0 1046
      .gitignore
  3. 67 36
      README.md
  4. 10 0
      config.yaml
  5. 33 0
      config/config.go
  6. 32 2
      go.mod
  7. 88 47
      go.sum
  8. 157 87
      main.go
  9. 0 118
      resouces/JsEnv.js
  10. 25 31
      resouces/JsEnv_Dev.js

+ 0 - 1049
.dockerignore

@@ -1,1049 +0,0 @@
-### MonoDevelop template
-#User Specific
-*.userprefs
-*.usertasks
-
-#Mono Project Files
-*.pidb
-*.resources
-test-results/
-
-### NotepadPP template
-# Notepad++ backups #
-*.bak
-
-### VisualStudioCode template
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
-*.code-workspace
-
-# Local History for Visual Studio Code
-.history/
-
-### VirtualEnv template
-# Virtualenv
-# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
-.Python
-[Bb]in
-[Ii]nclude
-[Ll]ib
-[Ll]ib64
-[Ll]ocal
-[Ss]cripts
-pyvenv.cfg
-.venv
-pip-selfcheck.json
-
-### Diff template
-*.patch
-*.diff
-
-### Eclipse template
-.metadata
-bin/
-tmp/
-*.tmp
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-.recommenders
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# PyDev specific (Python IDE for Eclipse)
-*.pydevproject
-
-# CDT-specific (C/C++ Development Tooling)
-.cproject
-
-# CDT- autotools
-.autotools
-
-# Java annotation processor (APT)
-.factorypath
-
-# PDT-specific (PHP Development Tools)
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# Tern plugin
-.tern-project
-
-# TeXlipse plugin
-.texlipse
-
-# STS (Spring Tool Suite)
-.springBeans
-
-# Code Recommenders
-.recommenders/
-
-# Annotation Processing
-.apt_generated/
-.apt_generated_test/
-
-# Scala IDE specific (Scala & Java development for Eclipse)
-.cache-main
-.scala_dependencies
-.worksheet
-
-# Uncomment this line if you wish to ignore the project description file.
-# Typically, this file would be tracked if it contains build/dependency configurations:
-#.project
-
-### EiffelStudio template
-# The compilation directory
-EIFGENs
-
-### Go template
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-
-# Test binary, built with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Dependency directories (remove the comment below to include it)
-# vendor/
-
-### Dreamweaver template
-# DW Dreamweaver added files
-_notes
-_compareTemp
-configs/
-dwsync.xml
-dw_php_codehinting.config
-*.mno
-
-### PuTTY template
-# Private key
-*.ppk
-
-### WebMethods template
-**/IntegrationServer/datastore/
-**/IntegrationServer/db/
-**/IntegrationServer/DocumentStore/
-**/IntegrationServer/lib/
-**/IntegrationServer/logs/
-**/IntegrationServer/replicate/
-**/IntegrationServer/sdk/
-**/IntegrationServer/support/
-**/IntegrationServer/update/
-**/IntegrationServer/userFtpRoot/
-**/IntegrationServer/web/
-**/IntegrationServer/WmRepository4/
-**/IntegrationServer/XAStore/
-**/IntegrationServer/packages/Wm*/
-
-### MATLAB template
-# Windows default autosave extension
-*.asv
-
-# OSX / *nix default autosave extension
-*.m~
-
-# Compiled MEX binaries (all platforms)
-*.mex*
-
-# Packaged app and toolbox files
-*.mlappinstall
-*.mltbx
-
-# Generated helpsearch folders
-helpsearch*/
-
-# Simulink code generation folders
-slprj/
-sccprj/
-
-# Matlab code generation folders
-codegen/
-
-# Simulink autosave extension
-*.autosave
-
-# Simulink cache files
-*.slxc
-
-# Octave session info
-octave-workspace
-
-### Vagrant template
-# General
-.vagrant/
-
-# Log files (if you are creating logs in debug mode, uncomment this)
-# *.log
-
-### MicrosoftOffice template
-
-# Word temporary
-~$*.doc*
-
-# Word Auto Backup File
-Backup of *.doc*
-
-# Excel temporary
-~$*.xls*
-
-# Excel Backup File
-*.xlk
-
-# PowerPoint temporary
-~$*.ppt*
-
-# Visio autosave temporary files
-*.~vsd*
-
-### JetBrains template
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-
-# Generated files
-.idea/**/contentModel.xml
-
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
-
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn.  Uncomment if using
-# auto-import.
-# .idea/artifacts
-# .idea/compiler.xml
-# .idea/jarRepositories.xml
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-# *.iml
-# *.ipr
-
-# CMake
-cmake-build-*/
-
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
-
-# File-based project format
-*.iws
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-# Android studio 3.1+ serialized cache file
-.idea/caches/build_file_checksums.ser
-
-### DartEditor template
-.project
-.buildlog
-
-### Ninja template
-.ninja_deps
-.ninja_log
-
-### Archives template
-# It's better to unpack these files and commit the raw source because
-# git has its own built in compression methods.
-*.7z
-*.jar
-*.rar
-*.zip
-*.gz
-*.gzip
-*.tgz
-*.bzip
-*.bzip2
-*.bz2
-*.xz
-*.lzma
-*.cab
-*.xar
-
-# Packing-only formats
-*.iso
-*.tar
-
-# Package management formats
-*.dmg
-*.xpi
-*.gem
-*.egg
-*.deb
-*.rpm
-*.msi
-*.msm
-*.msp
-*.txz
-
-### SynopsysVCS template
-# Waveform formats
-*.vcd
-*.vpd
-*.evcd
-*.fsdb
-
-# Default name of the simulation executable.  A different name can be
-# specified with this switch (the associated daidir database name is
-# also taken from here):  -o <path>/<filename>
-simv
-
-# Generated for Verilog and VHDL top configs
-simv.daidir/
-simv.db.dir/
-
-# Infrastructure necessary to co-simulate SystemC models with
-# Verilog/VHDL models.  An alternate directory may be specified with this
-# switch:  -Mdir=<directory_path>
-csrc/
-
-# Log file - the following switch allows to specify the file that will be
-# used to write all messages from simulation:  -l <filename>
-*.log
-
-# Coverage results (generated with urg) and database location.  The
-# following switch can also be used:  urg -dir <coverage_directory>.vdb
-simv.vdb/
-urgReport/
-
-# DVE and UCLI related files.
-DVEfiles/
-ucli.key
-
-# When the design is elaborated for DirectC, the following file is created
-# with declarations for C/C++ functions.
-vc_hdrs.h
-
-### Tags template
-# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
-TAGS
-.TAGS
-!TAGS/
-tags
-.tags
-!tags/
-gtags.files
-GTAGS
-GRTAGS
-GPATH
-GSYMS
-cscope.files
-cscope.out
-cscope.in.out
-cscope.po.out
-
-
-### TortoiseGit template
-# Project-level settings
-/.tgitconfig
-
-### Momentics template
-# Built files
-x86/
-arm/
-arm-p/
-translations/*.qm
-
-# IDE settings
-
-### Images template
-# JPEG
-*.jpg
-*.jpeg
-*.jpe
-*.jif
-*.jfif
-*.jfi
-
-# JPEG 2000
-*.jp2
-*.j2k
-*.jpf
-*.jpx
-*.jpm
-*.mj2
-
-# JPEG XR
-*.jxr
-*.hdp
-*.wdp
-
-# Graphics Interchange Format
-*.gif
-
-# RAW
-*.raw
-
-# Web P
-*.webp
-
-# Portable Network Graphics
-*.png
-
-# Animated Portable Network Graphics
-*.apng
-
-# Multiple-image Network Graphics
-*.mng
-
-# Tagged Image File Format
-*.tiff
-*.tif
-
-# Scalable Vector Graphics
-*.svg
-*.svgz
-
-# Portable Document Format
-*.pdf
-
-# X BitMap
-*.xbm
-
-# BMP
-*.bmp
-*.dib
-
-# ICO
-*.ico
-
-# 3D Images
-*.3dm
-*.max
-
-### Octave template
-# Windows default autosave extension
-
-# OSX / *nix default autosave extension
-
-# Compiled MEX binaries (all platforms)
-
-# Packaged app and toolbox files
-
-# Generated helpsearch folders
-
-# Simulink code generation folders
-
-# Matlab code generation folders
-
-# Simulink autosave extension
-
-# Simulink cache files
-
-# Octave session info
-
-### Stata template
-# .gitignore file for git projects containing Stata files
-# Commercial statistical software: http://www.stata.com
-
-# Stata dataset and output files
-*.dta
-*.gph
-*.smcl
-*.stpr
-*.stsem
-
-# Graphic export files from Stata
-# Stata command graph export: http://www.stata.com/manuals14/g-2graphexport.pdf
-#
-# You may add graphic export files to your .gitignore. However you should be
-# aware that this will exclude all image files from this main directory
-# and subdirectories.
-# *.ps
-# *.eps
-# *.wmf
-# *.emf
-# *.pdf
-# *.png
-# *.tif
-
-### KDevelop4 template
-*.kdev4
-.kdev4/
-
-### SlickEdit template
-# SlickEdit workspace and project files are ignored by default because
-# typically they are considered to be developer-specific and not part of a
-# project.
-*.vpw
-*.vpj
-
-# SlickEdit workspace history and tag files always contain user-specific
-# data so they should not be stored in a repository.
-*.vpwhistu
-*.vpwhist
-*.vtg
-
-### Linux template
-*~
-
-# temporary files which can be created if a process still has a handle open of a deleted file
-.fuse_hidden*
-
-# KDE directory preferences
-.directory
-
-# Linux trash folder which might appear on any partition or disk
-.Trash-*
-
-# .nfs files are created when an open file is removed but is still being accessed
-.nfs*
-
-### Ensime template
-# Ensime specific
-.ensime
-.ensime_cache/
-.ensime_lucene/
-
-### Emacs template
-# -*- mode: gitignore; -*-
-\#*\#
-/.emacs.desktop
-/.emacs.desktop.lock
-*.elc
-auto-save-list
-tramp
-.\#*
-
-# Org-mode
-.org-id-locations
-*_archive
-
-# flymake-mode
-*_flymake.*
-
-# eshell files
-/eshell/history
-/eshell/lastdir
-
-# elpa packages
-/elpa/
-
-# reftex files
-*.rel
-
-# AUCTeX auto folder
-/auto/
-
-# cask packages
-.cask/
-dist/
-
-# Flycheck
-flycheck_*.el
-
-# server auth directory
-/server/
-
-# projectiles files
-.projectile
-
-# directory configuration
-.dir-locals.el
-
-# network security
-/network-security.data
-
-
-### XilinxISE template
-# intermediate build files
-*.bgn
-*.bit
-*.bld
-*.cmd_log
-*.drc
-*.ll
-*.lso
-*.msd
-*.msk
-*.ncd
-*.ngc
-*.ngd
-*.ngr
-*.pad
-*.par
-*.pcf
-*.prj
-*.ptwx
-*.rbb
-*.rbd
-*.stx
-*.syr
-*.twr
-*.twx
-*.unroutes
-*.ut
-*.xst
-*_bitgen.xwbt
-*_envsettings.html
-*_map.map
-*_map.mrp
-*_map.ngm
-*_map.xrpt
-*_ngdbuild.xrpt
-*_pad.csv
-*_pad.txt
-*_par.xrpt
-*_summary.html
-*_summary.xml
-*_usage.xml
-*_xst.xrpt
-
-# iMPACT generated files
-_impactbatch.log
-impact.xsl
-impact_impact.xwbt
-ise_impact.cmd
-webtalk_impact.xml
-
-# Core Generator generated files
-xaw2verilog.log
-
-# project-wide generated files
-*.gise
-par_usage_statistics.html
-usage_statistics_webtalk.html
-webtalk.log
-webtalk_pn.xml
-
-# generated folders
-iseconfig/
-xlnx_auto_0_xdb/
-xst/
-_ngo/
-_xmsgs/
-
-### Ansible template
-*.retry
-
-### Calabash template
-# Calabash / Cucumber
-rerun/
-reports/
-screenshots/
-screenshot*.png
-test-servers/
-
-# bundler
-.bundle
-vendor
-
-### Patch template
-*.orig
-*.rej
-
-### Cloud9 template
-# Cloud9 IDE - http://c9.io
-.c9revisions
-.c9
-
-### CVS template
-/CVS/*
-**/CVS/*
-.cvsignore
-*/.cvsignore
-
-### Xcode template
-# Xcode
-#
-# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
-
-## User settings
-xcuserdata/
-
-## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
-*.xcscmblueprint
-*.xccheckout
-
-## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
-build/
-DerivedData/
-*.moved-aside
-*.pbxuser
-!default.pbxuser
-*.mode1v3
-!default.mode1v3
-*.mode2v3
-!default.mode2v3
-*.perspectivev3
-!default.perspectivev3
-
-## Gcc Patch
-/*.gcno
-
-### Kate template
-# Swap Files #
-.*.kate-swp
-.swp.*
-
-### Mercurial template
-.hg/
-.hgignore
-.hgsigs
-.hgsub
-.hgsubstate
-.hgtags
-
-### Metals template
- # Generated Metals (Scala Language Server) files
- # Reference: https://scalameta.org/metals/
-.metals/
-.bloop/
-project/metals.sbt
-
-### Backup template
-*.gho
-*.ori
-
-### LyX template
-# Ignore LyX backup and autosave files
-# http://www.lyx.org/
-*.lyx~
-*.lyx#
-
-### SVN template
-.svn/
-
-### Windows template
-# Windows thumbnail cache files
-Thumbs.db
-Thumbs.db:encryptable
-ehthumbs.db
-ehthumbs_vista.db
-
-# Dump file
-*.stackdump
-
-# Folder config file
-[Dd]esktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Windows Installer files
-*.msix
-
-# Windows shortcuts
-*.lnk
-
-### FlexBuilder template
-bin-debug/
-bin-release/
-
-### SublimeText template
-# Cache files for Sublime Text
-*.tmlanguage.cache
-*.tmPreferences.cache
-*.stTheme.cache
-
-# Workspace files are user-specific
-*.sublime-workspace
-
-# Project files should be checked into the repository, unless a significant
-# proportion of contributors will probably not be using Sublime Text
-# *.sublime-project
-
-# SFTP configuration file
-sftp-config.json
-sftp-config-alt*.json
-
-# Package control specific files
-Package Control.last-run
-Package Control.ca-list
-Package Control.ca-bundle
-Package Control.system-ca-bundle
-Package Control.cache/
-Package Control.ca-certs/
-Package Control.merged-ca-bundle
-Package Control.user-ca-bundle
-oscrypto-ca-bundle.crt
-bh_unicode_properties.cache
-
-# Sublime-github package stores a github token in this file
-# https://packagecontrol.io/packages/sublime-github
-GitHub.sublime-settings
-
-### Lazarus template
-# Lazarus compiler-generated binaries (safe to delete)
-*.lrs
-*.res
-*.compiled
-*.dbg
-*.ppu
-*.o
-*.or
-*.a
-
-# Lazarus autogenerated files (duplicated info)
-*.rst
-*.rsj
-*.lrt
-
-# Lazarus local files (user-specific info)
-*.lps
-
-# Lazarus backups and unit output folders.
-# These can be changed by user in Lazarus/project options.
-backup/
-lib/
-
-# Application bundle for Mac OS
-*.app/
-
-### CodeKit template
-# General CodeKit files to ignore
-config.codekit
-config.codekit3
-/min
-
-### BricxCC template
-# Bricx Command Center IDE
-# http://bricxcc.sourceforge.net
-*.sym
-
-### Bazaar template
-.bzr/
-.bzrignore
-
-### LibreOffice template
-# LibreOffice locks
-.~lock.*#
-
-### Dropbox template
-# Dropbox settings and caches
-.dropbox
-.dropbox.attr
-.dropbox.cache
-
-### PSoCCreator template
-# Project Settings
-*.cywrk.*
-*.cyprj.*
-
-# Generated Assets and Resources
-Debug/
-Release/
-Export/
-*/codegentemp
-*/Generated_Source
-*_datasheet.pdf
-*_timing.html
-*.cycdx
-*.cyfit
-*.rpt
-*.svd
-
-### macOS template
-# General
-.DS_Store
-.AppleDouble
-.LSOverride
-
-# Icon must end with two \r
-Icon
-
-# Thumbnails
-._*
-
-# Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-
-# Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-### JEnv template
-# JEnv local Java version configuration file
-.java-version
-
-# Used by previous versions of JEnv
-.jenv-version
-
-### SBT template
-# Simple Build Tool
-# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
-
-dist/*
-target/
-lib_managed/
-src_managed/
-project/boot/
-project/plugins/project/
-.history
-.cache
-.lib/
-
-### Otto template
-.otto/
-
-### Espresso template
-*.esproj
-
-### Redcar template
-.redcar
-
-### Redis template
-# Ignore redis binary dump (dump.rdb) files
-
-*.rdb
-
-### Anjuta template
-# Local configuration folder and symbol database
-/.anjuta/
-/.anjuta_sym_db.db
-
-### NetBeans template
-**/nbproject/private/
-**/nbproject/Makefile-*.mk
-**/nbproject/Package-*.bash
-nbbuild/
-nbdist/
-.nb-gradle/
-
-### TextMate template
-*.tmproj
-*.tmproject
-tmtags
-
-### ModelSim template
-# ignore ModelSim generated files and directories (temp files and so on)
-[_@]*
-
-# ignore compilation output of ModelSim
-*.mti
-*.dat
-*.dbs
-*.psm
-*.cmp
-*.html
-*.bsf
-
-# ignore simulation output of ModelSim
-wlf*
-*.wlf
-*.vstf
-*.ucdb
-cov*/
-transcript*
-sc_dpiheader.h
-vsim.dbg
-
-### Vim template
-# Swap
-[._]*.s[a-v][a-z]
-!*.svg  # comment out if you don't need vector files
-[._]*.sw[a-p]
-[._]s[a-rt-v][a-z]
-[._]ss[a-gi-z]
-[._]sw[a-p]
-
-# Session
-Session.vim
-Sessionx.vim
-
-# Temporary
-.netrwhist
-# Auto-generated tag files
-# Persistent undo
-[._]*.un~
-
-### JDeveloper template
-# default application storage directory used by the IDE Performance Cache feature
-.data/
-
-# used for ADF styles caching
-temp/
-
-# default output directories
-classes/
-deploy/
-javadoc/
-
-# lock file, a part of Oracle Credential Store Framework
-cwallet.sso.lck
-### Virtuoso template
-# Gitignore for Cadence Virtuoso
-################################################################
-
-# Log files
-panic*.log.*
-
-# OpenAccess database lock files
-*.cdslck*
-
-# Run directories for layout vs. schematic and design rule check
-lvsRunDir/*
-drcRunDir/*
-
-# Abstract generation tool
-abstract.log*
-abstract.record*
-
-
-### GPG template
-secring.*
-
-
-.idea/
-resouces/
-Deployments/

+ 0 - 1046
.gitignore

@@ -1,1046 +0,0 @@
-### MonoDevelop template
-#User Specific
-*.userprefs
-*.usertasks
-
-#Mono Project Files
-*.pidb
-*.resources
-test-results/
-
-### NotepadPP template
-# Notepad++ backups #
-*.bak
-
-### VisualStudioCode template
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
-*.code-workspace
-
-# Local History for Visual Studio Code
-.history/
-
-### VirtualEnv template
-# Virtualenv
-# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
-.Python
-[Bb]in
-[Ii]nclude
-[Ll]ib
-[Ll]ib64
-[Ll]ocal
-[Ss]cripts
-pyvenv.cfg
-.venv
-pip-selfcheck.json
-
-### Diff template
-*.patch
-*.diff
-
-### Eclipse template
-.metadata
-bin/
-tmp/
-*.tmp
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-.recommenders
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# PyDev specific (Python IDE for Eclipse)
-*.pydevproject
-
-# CDT-specific (C/C++ Development Tooling)
-.cproject
-
-# CDT- autotools
-.autotools
-
-# Java annotation processor (APT)
-.factorypath
-
-# PDT-specific (PHP Development Tools)
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# Tern plugin
-.tern-project
-
-# TeXlipse plugin
-.texlipse
-
-# STS (Spring Tool Suite)
-.springBeans
-
-# Code Recommenders
-.recommenders/
-
-# Annotation Processing
-.apt_generated/
-.apt_generated_test/
-
-# Scala IDE specific (Scala & Java development for Eclipse)
-.cache-main
-.scala_dependencies
-.worksheet
-
-# Uncomment this line if you wish to ignore the project description file.
-# Typically, this file would be tracked if it contains build/dependency configurations:
-#.project
-
-### EiffelStudio template
-# The compilation directory
-EIFGENs
-
-### Go template
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-
-# Test binary, built with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Dependency directories (remove the comment below to include it)
-# vendor/
-
-### Dreamweaver template
-# DW Dreamweaver added files
-_notes
-_compareTemp
-configs/
-dwsync.xml
-dw_php_codehinting.config
-*.mno
-
-### PuTTY template
-# Private key
-*.ppk
-
-### WebMethods template
-**/IntegrationServer/datastore/
-**/IntegrationServer/db/
-**/IntegrationServer/DocumentStore/
-**/IntegrationServer/lib/
-**/IntegrationServer/logs/
-**/IntegrationServer/replicate/
-**/IntegrationServer/sdk/
-**/IntegrationServer/support/
-**/IntegrationServer/update/
-**/IntegrationServer/userFtpRoot/
-**/IntegrationServer/web/
-**/IntegrationServer/WmRepository4/
-**/IntegrationServer/XAStore/
-**/IntegrationServer/packages/Wm*/
-
-### MATLAB template
-# Windows default autosave extension
-*.asv
-
-# OSX / *nix default autosave extension
-*.m~
-
-# Compiled MEX binaries (all platforms)
-*.mex*
-
-# Packaged app and toolbox files
-*.mlappinstall
-*.mltbx
-
-# Generated helpsearch folders
-helpsearch*/
-
-# Simulink code generation folders
-slprj/
-sccprj/
-
-# Matlab code generation folders
-codegen/
-
-# Simulink autosave extension
-*.autosave
-
-# Simulink cache files
-*.slxc
-
-# Octave session info
-octave-workspace
-
-### Vagrant template
-# General
-.vagrant/
-
-# Log files (if you are creating logs in debug mode, uncomment this)
-# *.log
-
-### MicrosoftOffice template
-
-# Word temporary
-~$*.doc*
-
-# Word Auto Backup File
-Backup of *.doc*
-
-# Excel temporary
-~$*.xls*
-
-# Excel Backup File
-*.xlk
-
-# PowerPoint temporary
-~$*.ppt*
-
-# Visio autosave temporary files
-*.~vsd*
-
-### JetBrains template
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-
-# Generated files
-.idea/**/contentModel.xml
-
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
-
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn.  Uncomment if using
-# auto-import.
-# .idea/artifacts
-# .idea/compiler.xml
-# .idea/jarRepositories.xml
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-# *.iml
-# *.ipr
-
-# CMake
-cmake-build-*/
-
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
-
-# File-based project format
-*.iws
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-# Android studio 3.1+ serialized cache file
-.idea/caches/build_file_checksums.ser
-
-### DartEditor template
-.project
-.buildlog
-
-### Ninja template
-.ninja_deps
-.ninja_log
-
-### Archives template
-# It's better to unpack these files and commit the raw source because
-# git has its own built in compression methods.
-*.7z
-*.jar
-*.rar
-*.zip
-*.gz
-*.gzip
-*.tgz
-*.bzip
-*.bzip2
-*.bz2
-*.xz
-*.lzma
-*.cab
-*.xar
-
-# Packing-only formats
-*.iso
-*.tar
-
-# Package management formats
-*.dmg
-*.xpi
-*.gem
-*.egg
-*.deb
-*.rpm
-*.msi
-*.msm
-*.msp
-*.txz
-
-### SynopsysVCS template
-# Waveform formats
-*.vcd
-*.vpd
-*.evcd
-*.fsdb
-
-# Default name of the simulation executable.  A different name can be
-# specified with this switch (the associated daidir database name is
-# also taken from here):  -o <path>/<filename>
-simv
-
-# Generated for Verilog and VHDL top configs
-simv.daidir/
-simv.db.dir/
-
-# Infrastructure necessary to co-simulate SystemC models with
-# Verilog/VHDL models.  An alternate directory may be specified with this
-# switch:  -Mdir=<directory_path>
-csrc/
-
-# Log file - the following switch allows to specify the file that will be
-# used to write all messages from simulation:  -l <filename>
-*.log
-
-# Coverage results (generated with urg) and database location.  The
-# following switch can also be used:  urg -dir <coverage_directory>.vdb
-simv.vdb/
-urgReport/
-
-# DVE and UCLI related files.
-DVEfiles/
-ucli.key
-
-# When the design is elaborated for DirectC, the following file is created
-# with declarations for C/C++ functions.
-vc_hdrs.h
-
-### Tags template
-# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
-TAGS
-.TAGS
-!TAGS/
-tags
-.tags
-!tags/
-gtags.files
-GTAGS
-GRTAGS
-GPATH
-GSYMS
-cscope.files
-cscope.out
-cscope.in.out
-cscope.po.out
-
-
-### TortoiseGit template
-# Project-level settings
-/.tgitconfig
-
-### Momentics template
-# Built files
-x86/
-arm/
-arm-p/
-translations/*.qm
-
-# IDE settings
-
-### Images template
-# JPEG
-*.jpg
-*.jpeg
-*.jpe
-*.jif
-*.jfif
-*.jfi
-
-# JPEG 2000
-*.jp2
-*.j2k
-*.jpf
-*.jpx
-*.jpm
-*.mj2
-
-# JPEG XR
-*.jxr
-*.hdp
-*.wdp
-
-# Graphics Interchange Format
-*.gif
-
-# RAW
-*.raw
-
-# Web P
-*.webp
-
-# Portable Network Graphics
-*.png
-
-# Animated Portable Network Graphics
-*.apng
-
-# Multiple-image Network Graphics
-*.mng
-
-# Tagged Image File Format
-*.tiff
-*.tif
-
-# Scalable Vector Graphics
-*.svg
-*.svgz
-
-# Portable Document Format
-*.pdf
-
-# X BitMap
-*.xbm
-
-# BMP
-*.bmp
-*.dib
-
-# ICO
-*.ico
-
-# 3D Images
-*.3dm
-*.max
-
-### Octave template
-# Windows default autosave extension
-
-# OSX / *nix default autosave extension
-
-# Compiled MEX binaries (all platforms)
-
-# Packaged app and toolbox files
-
-# Generated helpsearch folders
-
-# Simulink code generation folders
-
-# Matlab code generation folders
-
-# Simulink autosave extension
-
-# Simulink cache files
-
-# Octave session info
-
-### Stata template
-# .gitignore file for git projects containing Stata files
-# Commercial statistical software: http://www.stata.com
-
-# Stata dataset and output files
-*.dta
-*.gph
-*.smcl
-*.stpr
-*.stsem
-
-# Graphic export files from Stata
-# Stata command graph export: http://www.stata.com/manuals14/g-2graphexport.pdf
-#
-# You may add graphic export files to your .gitignore. However you should be
-# aware that this will exclude all image files from this main directory
-# and subdirectories.
-# *.ps
-# *.eps
-# *.wmf
-# *.emf
-# *.pdf
-# *.png
-# *.tif
-
-### KDevelop4 template
-*.kdev4
-.kdev4/
-
-### SlickEdit template
-# SlickEdit workspace and project files are ignored by default because
-# typically they are considered to be developer-specific and not part of a
-# project.
-*.vpw
-*.vpj
-
-# SlickEdit workspace history and tag files always contain user-specific
-# data so they should not be stored in a repository.
-*.vpwhistu
-*.vpwhist
-*.vtg
-
-### Linux template
-*~
-
-# temporary files which can be created if a process still has a handle open of a deleted file
-.fuse_hidden*
-
-# KDE directory preferences
-.directory
-
-# Linux trash folder which might appear on any partition or disk
-.Trash-*
-
-# .nfs files are created when an open file is removed but is still being accessed
-.nfs*
-
-### Ensime template
-# Ensime specific
-.ensime
-.ensime_cache/
-.ensime_lucene/
-
-### Emacs template
-# -*- mode: gitignore; -*-
-\#*\#
-/.emacs.desktop
-/.emacs.desktop.lock
-*.elc
-auto-save-list
-tramp
-.\#*
-
-# Org-mode
-.org-id-locations
-*_archive
-
-# flymake-mode
-*_flymake.*
-
-# eshell files
-/eshell/history
-/eshell/lastdir
-
-# elpa packages
-/elpa/
-
-# reftex files
-*.rel
-
-# AUCTeX auto folder
-/auto/
-
-# cask packages
-.cask/
-dist/
-
-# Flycheck
-flycheck_*.el
-
-# server auth directory
-/server/
-
-# projectiles files
-.projectile
-
-# directory configuration
-.dir-locals.el
-
-# network security
-/network-security.data
-
-
-### XilinxISE template
-# intermediate build files
-*.bgn
-*.bit
-*.bld
-*.cmd_log
-*.drc
-*.ll
-*.lso
-*.msd
-*.msk
-*.ncd
-*.ngc
-*.ngd
-*.ngr
-*.pad
-*.par
-*.pcf
-*.prj
-*.ptwx
-*.rbb
-*.rbd
-*.stx
-*.syr
-*.twr
-*.twx
-*.unroutes
-*.ut
-*.xst
-*_bitgen.xwbt
-*_envsettings.html
-*_map.map
-*_map.mrp
-*_map.ngm
-*_map.xrpt
-*_ngdbuild.xrpt
-*_pad.csv
-*_pad.txt
-*_par.xrpt
-*_summary.html
-*_summary.xml
-*_usage.xml
-*_xst.xrpt
-
-# iMPACT generated files
-_impactbatch.log
-impact.xsl
-impact_impact.xwbt
-ise_impact.cmd
-webtalk_impact.xml
-
-# Core Generator generated files
-xaw2verilog.log
-
-# project-wide generated files
-*.gise
-par_usage_statistics.html
-usage_statistics_webtalk.html
-webtalk.log
-webtalk_pn.xml
-
-# generated folders
-iseconfig/
-xlnx_auto_0_xdb/
-xst/
-_ngo/
-_xmsgs/
-
-### Ansible template
-*.retry
-
-### Calabash template
-# Calabash / Cucumber
-rerun/
-reports/
-screenshots/
-screenshot*.png
-test-servers/
-
-# bundler
-.bundle
-vendor
-
-### Patch template
-*.orig
-*.rej
-
-### Cloud9 template
-# Cloud9 IDE - http://c9.io
-.c9revisions
-.c9
-
-### CVS template
-/CVS/*
-**/CVS/*
-.cvsignore
-*/.cvsignore
-
-### Xcode template
-# Xcode
-#
-# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
-
-## User settings
-xcuserdata/
-
-## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
-*.xcscmblueprint
-*.xccheckout
-
-## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
-build/
-DerivedData/
-*.moved-aside
-*.pbxuser
-!default.pbxuser
-*.mode1v3
-!default.mode1v3
-*.mode2v3
-!default.mode2v3
-*.perspectivev3
-!default.perspectivev3
-
-## Gcc Patch
-/*.gcno
-
-### Kate template
-# Swap Files #
-.*.kate-swp
-.swp.*
-
-### Mercurial template
-.hg/
-.hgignore
-.hgsigs
-.hgsub
-.hgsubstate
-.hgtags
-
-### Metals template
- # Generated Metals (Scala Language Server) files
- # Reference: https://scalameta.org/metals/
-.metals/
-.bloop/
-project/metals.sbt
-
-### Backup template
-*.gho
-*.ori
-
-### LyX template
-# Ignore LyX backup and autosave files
-# http://www.lyx.org/
-*.lyx~
-*.lyx#
-
-### SVN template
-.svn/
-
-### Windows template
-# Windows thumbnail cache files
-Thumbs.db
-Thumbs.db:encryptable
-ehthumbs.db
-ehthumbs_vista.db
-
-# Dump file
-*.stackdump
-
-# Folder config file
-[Dd]esktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Windows Installer files
-*.msix
-
-# Windows shortcuts
-*.lnk
-
-### FlexBuilder template
-bin-debug/
-bin-release/
-
-### SublimeText template
-# Cache files for Sublime Text
-*.tmlanguage.cache
-*.tmPreferences.cache
-*.stTheme.cache
-
-# Workspace files are user-specific
-*.sublime-workspace
-
-# Project files should be checked into the repository, unless a significant
-# proportion of contributors will probably not be using Sublime Text
-# *.sublime-project
-
-# SFTP configuration file
-sftp-config.json
-sftp-config-alt*.json
-
-# Package control specific files
-Package Control.last-run
-Package Control.ca-list
-Package Control.ca-bundle
-Package Control.system-ca-bundle
-Package Control.cache/
-Package Control.ca-certs/
-Package Control.merged-ca-bundle
-Package Control.user-ca-bundle
-oscrypto-ca-bundle.crt
-bh_unicode_properties.cache
-
-# Sublime-github package stores a github token in this file
-# https://packagecontrol.io/packages/sublime-github
-GitHub.sublime-settings
-
-### Lazarus template
-# Lazarus compiler-generated binaries (safe to delete)
-*.lrs
-*.res
-*.compiled
-*.dbg
-*.ppu
-*.o
-*.or
-*.a
-
-# Lazarus autogenerated files (duplicated info)
-*.rst
-*.rsj
-*.lrt
-
-# Lazarus local files (user-specific info)
-*.lps
-
-# Lazarus backups and unit output folders.
-# These can be changed by user in Lazarus/project options.
-backup/
-lib/
-
-# Application bundle for Mac OS
-*.app/
-
-### CodeKit template
-# General CodeKit files to ignore
-config.codekit
-config.codekit3
-/min
-
-### BricxCC template
-# Bricx Command Center IDE
-# http://bricxcc.sourceforge.net
-*.sym
-
-### Bazaar template
-.bzr/
-.bzrignore
-
-### LibreOffice template
-# LibreOffice locks
-.~lock.*#
-
-### Dropbox template
-# Dropbox settings and caches
-.dropbox
-.dropbox.attr
-.dropbox.cache
-
-### PSoCCreator template
-# Project Settings
-*.cywrk.*
-*.cyprj.*
-
-# Generated Assets and Resources
-Debug/
-Release/
-Export/
-*/codegentemp
-*/Generated_Source
-*_datasheet.pdf
-*_timing.html
-*.cycdx
-*.cyfit
-*.rpt
-*.svd
-
-### macOS template
-# General
-.DS_Store
-.AppleDouble
-.LSOverride
-
-# Icon must end with two \r
-Icon
-
-# Thumbnails
-._*
-
-# Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-
-# Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-### JEnv template
-# JEnv local Java version configuration file
-.java-version
-
-# Used by previous versions of JEnv
-.jenv-version
-
-### SBT template
-# Simple Build Tool
-# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
-
-dist/*
-target/
-lib_managed/
-src_managed/
-project/boot/
-project/plugins/project/
-.history
-.cache
-.lib/
-
-### Otto template
-.otto/
-
-### Espresso template
-*.esproj
-
-### Redcar template
-.redcar
-
-### Redis template
-# Ignore redis binary dump (dump.rdb) files
-
-*.rdb
-
-### Anjuta template
-# Local configuration folder and symbol database
-/.anjuta/
-/.anjuta_sym_db.db
-
-### NetBeans template
-**/nbproject/private/
-**/nbproject/Makefile-*.mk
-**/nbproject/Package-*.bash
-nbbuild/
-nbdist/
-.nb-gradle/
-
-### TextMate template
-*.tmproj
-*.tmproject
-tmtags
-
-### ModelSim template
-# ignore ModelSim generated files and directories (temp files and so on)
-[_@]*
-
-# ignore compilation output of ModelSim
-*.mti
-*.dat
-*.dbs
-*.psm
-*.cmp
-*.html
-*.bsf
-
-# ignore simulation output of ModelSim
-wlf*
-*.wlf
-*.vstf
-*.ucdb
-cov*/
-transcript*
-sc_dpiheader.h
-vsim.dbg
-
-### Vim template
-# Swap
-[._]*.s[a-v][a-z]
-!*.svg  # comment out if you don't need vector files
-[._]*.sw[a-p]
-[._]s[a-rt-v][a-z]
-[._]ss[a-gi-z]
-[._]sw[a-p]
-
-# Session
-Session.vim
-Sessionx.vim
-
-# Temporary
-.netrwhist
-# Auto-generated tag files
-# Persistent undo
-[._]*.un~
-
-### JDeveloper template
-# default application storage directory used by the IDE Performance Cache feature
-.data/
-
-# used for ADF styles caching
-temp/
-
-# default output directories
-classes/
-deploy/
-javadoc/
-
-# lock file, a part of Oracle Credential Store Framework
-cwallet.sso.lck
-### Virtuoso template
-# Gitignore for Cadence Virtuoso
-################################################################
-
-# Log files
-panic*.log.*
-
-# OpenAccess database lock files
-*.cdslck*
-
-# Run directories for layout vs. schematic and design rule check
-lvsRunDir/*
-drcRunDir/*
-
-# Abstract generation tool
-abstract.log*
-abstract.record*
-
-
-### GPG template
-secring.*
-.idea/
-

+ 67 - 36
README.md

@@ -1,17 +1,25 @@
-# JsRPC
+```dart
+
+       __       _______..______      .______     ______ 
+      |  |     /       ||   _  \     |   _  \   /      |
+      |  |    |   (----`|  |_)  |    |  |_)  | |  ,----'
+.--.  |  |     \   \    |      /     |   ___/  |  |     
+|  `--'  | .----)   |   |  |\  \----.|  |      |  `----.
+ \______/  |_______/    | _| `._____|| _|       \______|
+
+```
 
 
 -- js逆向之远程调用(rpc)免去抠代码补环境
 
 > 黑脸怪
 <!-- TOC -->
-* [JsRPC](#jsrpc)
   * [目录结构](#目录结构)
   * [基本介绍](#基本介绍)
   * [实现](#实现)
   * [食用方法](#食用方法)
     * [打开编译好的文件,开启服务(releases下载)](#打开编译好的文件开启服务releases下载)
-    * [注入JS,构建通信环境(/resouces/JsEnv_Dev.js)](#注入js构建通信环境resoucesjsenvdevjs)
+    * [注入JS,构建通信环境(/resouces/JsEnv_De.js)](#注入js构建通信环境resoucesjsenv_dejs)
     * [连接通信](#连接通信)
       * [I 远程调用0:](#i-远程调用0)
         * [接口传js代码让浏览器执行](#接口传js代码让浏览器执行)
@@ -20,6 +28,7 @@
         * [远程调用2:带参获取值](#远程调用2带参获取值)
         * [远程调用3:带多个参获 并且使用post方式 取值](#远程调用3带多个参获-并且使用post方式-取值)
   * [食用案例-爬虫练手-xx网第15题](#食用案例-爬虫练手-xx网第15题)
+  * [其他说明](#其他说明)
   * [BUG修复](#bug修复)
   * [其他案例](#其他案例)
   * [常见问题](#常见问题)
@@ -31,6 +40,7 @@
 ```dart
 -- main.go (服务器的主代码)
 -- resouces/JsEnv_Dev.js (客户端注入js环境)
+-- config.yaml (可选配置文件)
 ```
 
 ## 基本介绍
@@ -43,21 +53,17 @@
 
 > 说明:本方法可以https证书且支持wss
 
-在https的网站想要新建WebSocket连接如果是连接到普通的ws会报安全错误,连接本地(127.0.0.1)不会报错~ 可以用本地和wss 你自己看着玩
-
-1. 无https证书者。直接编译main.go 使用本地ip(127.0.0.1)可以在https的网站直接连接ws使用 默认端口12080
-2. 有https证书者。修改main.go文件 把r.Run()注释掉,把r.RunTls注释取消掉 并且参数设置证书的路径 直接输入名字就是当前路径 默认端口:12443
-
 
 ## 食用方法
 
 ### 打开编译好的文件,开启服务(releases下载)
 
-如下图所示
-![image](https://user-images.githubusercontent.com/41224971/161306799-57f009dc-5448-402f-ab4d-ee5c6c969c91.png)
+如图所示
 
-1.01版本默认不打印日志
-如需要打印日志,请用命令行启动(程序后面加个log) ".\rpc.exe log"
+<img width="570" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/2530274f-33b9-4ccd-8749-6431abea27b2">
+
+如需更改部分配置,请下载config.yaml文件 并且放在服务程序的同级路径  
+[config.yaml]([链接地址](https://github.com/jxhczhl/JsRpc/blob/main/config.yaml))
 
 **api 简介**
 
@@ -67,22 +73,28 @@
 - `/go` :获取数据的接口  (get | post)
 - `/execjs` :传递jscode给浏览器执行 (get | post)
 
-说明:接口用?group和name来区分任务 如 ws://127.0.0.1:12080/ws?group={}&name={}"
-  //注入ws的例子 group和name都可以随便起名(必填)
-http://127.0.0.1:12080/go?group={}&name={}&action={}&param={} //这是调用的接口
-group和name填写上面注入时候的,action是注册的方法名,param是可选的参数 接口参数暂定为这几个,但是param还可以传stringify过的json(字符串) 下面会介绍
+说明:接口用?group分组 如 "ws://127.0.0.1:12080/ws?group={}"
+以及可选参数 clientId
+clientId说明:以group分组后,如果有注册相同group的 可以传入这个id来区分客户端,如果不传 服务程序会自动生成一个。当访问调用接口时,服务程序随机发送请求到相同group的客户端里。
+
+//注入例子 group可以随便起名(必填)
+http://127.0.0.1:12080/go?group={}&action={}&param={} //这是调用的接口
+group填写上面注入时候的,action是注册的方法名,param是可选的参数 param可以传string类型或者object类型(会尝试用JSON.parse)
+
+### 注入JS,构建通信环境([/resouces/JsEnv_De.js](https://github.com/jxhczhl/JsRpc/blob/main/resouces/JsEnv_Dev.js))
 
-### 注入JS,构建通信环境(/resouces/JsEnv_Dev.js)
+打开JsEnv 复制粘贴到网站控制台(注意:可以在浏览器开启的时候就先注入环境,不要在调试断点时候注入)
 
-打开JsEnv 复制粘贴到网站控制台(注意:可以在浏览器开启的时候就先注入环境,不然要放开调试断点才能注入)
+<img width="856" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/9fbc413d-6a97-41e1-9aa4-2c6d0b7c7dd6">
 
-![image](https://user-images.githubusercontent.com/41224971/161307187-1265ec7c-fe64-45d7-b255-5472e0f25802.png)
 
 ### 连接通信
 
 ```js
 // 注入环境后连接通信
-var demo = new Hlclient("ws://127.0.0.1:12080/ws?group=zzz&name=hlg");
+var demo = new Hlclient("ws://127.0.0.1:12080/ws?group=zzz");
+// 可选  
+var demo = new Hlclient("ws://127.0.0.1:12080/ws?group=zzz&clientId="+new Date().getTime())
 ```
 
 #### I 远程调用0:
@@ -104,7 +116,6 @@ jscode = """
 url = "http://localhost:12080/execjs"
 data = {
     "group": "zzz",
-    "name": "hlg",
     "jscode":jscode
 }
 res = requests.post(url, data=data)
@@ -128,20 +139,13 @@ demo.regAction("hello", function (resolve) {
 })
 
 
-// 异步的代码注册:
-demo.regAction('token', async (resolve) => {
-  let token = await grecaptcha.execute(0, { action: '' }).then(function (token) {
-    return token
-  });
-  resolve(token);
-})
-
 ```
 
-    访问接口,获得js端的返回值
-    http://localhost:12080/go?group=zzz&name=hlg&action=hello
+访问接口,获得js端的返回值  
+http://localhost:12080/go?group=zzz&name=hlg&action=hello
+
+<img width="1144" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/5f0da051-18f3-49ac-98f8-96f408440475">
 
-![image](https://user-images.githubusercontent.com/41224971/161309382-81a9a9cc-65f7-4531-a1e6-a892dfe1facd.png)
 
 ##### 远程调用2:带参获取值
 
@@ -154,7 +158,10 @@ demo.regAction("hello2", function (resolve,param) {
 })
 ```
 
-    访问接口,获得js端的返回值![image](https://user-images.githubusercontent.com/41224971/161311297-6731c089-3de2-44ed-80b9-21a03746a52c.png)
+访问接口,获得js端的返回值
+
+<img width="848" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/91b993ae-7831-4b65-8553-f90e19cc7ebe">
+
 
 ##### 远程调用3:带多个参获 并且使用post方式 取值
 
@@ -171,13 +178,12 @@ demo.regAction("hello3", function (resolve,param) {
 })
 ```
 
-   访问接口,获得js端的返回值
+访问接口,获得js端的返回值
 
 ```python
 url = "http://localhost:12080/go"
 data = {
     "group": "zzz",
-    "name": "hlg",
     "action": "hello3",
     "param": json.dumps({"user":"黑脸怪","status":"好困啊"})
 }
@@ -186,7 +192,8 @@ res=requests.post(url, data=data) #这里换get也是可以的
 print(res.text)
 ```
 
-![image](https://user-images.githubusercontent.com/41224971/161313397-166cbda0-fe8b-4063-b815-376902d82f74.png)
+<img width="1145" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/5af9bf90-cdfd-4d89-a3c0-a11a54ca7969">
+
 
 ## 食用案例-爬虫练手-xx网第15题
 
@@ -207,6 +214,21 @@ print(res.text)
 
     控制台可以关,但是注入的网页不要关哦
 
+## 其他说明
+如果需要更改rpc服务的一些配置 比如端口号啊,https/wss服务,打印日志等  
+可以在执行文件的同路径 下载[config.yaml]([链接地址](https://github.com/jxhczhl/JsRpc/blob/main/config.yaml))文件配置  
+<img width="879" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/ad023b16-65b5-418e-8494-e988bb02fb12">
+
+group说明  
+一般配置group名字不一样分开调用就行  
+特别情况,可以一样的group名,比如3个客户端(标签演示)执行加密,程序会随机一个客户端来执行并返回。  
+<img width="1810" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/6c111aea-1550-4683-a0c2-ed3c7e232d5a">
+请确保action也都是一样  
+<img width="1934" alt="image" src="https://github.com/jxhczhl/JsRpc/assets/41224971/f6e0d713-6f5f-4d7d-b5e9-d7eb2d8316ae">
+多个group除了随机 还可以根据clientId指定客户端执行  
+http://127.0.0.1:12080/go?group=zzz&action=hello  
+http://127.0.0.1:12080/go?group=zzz&action=hello&clientId=hliang1713564563459  可选
+
 ## BUG修复
 
 1.修复ResultSet函数,在并发处理环境下存在数据丢失,响应延迟等问题。
@@ -232,5 +254,14 @@ print(res.text)
 
 ## TODO
 
+- [ ] 异步方法调用
+```js
+demo.regAction('token', async (resolve) => {
+    let token = await grecaptcha.execute(0, { action: '' }).then(function (token) {
+        return token
+    });
+    resolve(token);
+})
+```
 - [ ] ssl Docker Deploy
 - [ ] K8s Deploy

+ 10 - 0
config.yaml

@@ -0,0 +1,10 @@
+BasicListen: "0.0.0.0:12080" # 不想暴露公网/局域网可改成127.0.0.1:port
+HttpsServices:
+  IsEnable: false # 是否启用https/wss服务
+  HttpsListen: "0.0.0.0:12443"
+  PemPath: "hl98.cn.pem"
+  KeyPath: "hl98.cn.key"
+
+DefaultTimeOut: 30 # 当执行端没有返回值时,等待%d秒返回超时
+CloseLog: false # 关闭一些日志
+CloseWebLog: false # 关闭Web服务访问的日志

+ 33 - 0
config/config.go

@@ -0,0 +1,33 @@
+package config
+
+import (
+	"gopkg.in/yaml.v3"
+	"os"
+)
+
+func InitConf(path string, conf *ConfStruct) (err error) {
+	fileContent, err := os.ReadFile(path)
+	if err != nil {
+		return
+	}
+	if err = yaml.Unmarshal(fileContent, &conf); err != nil {
+		return
+	}
+	return
+}
+
+type ConfStruct struct {
+	BasicListen    string      `yaml:"BasicListen"`
+	HttpsServices  HttpsConfig `yaml:"HttpsServices"`
+	DefaultTimeOut int         `yaml:"DefaultTimeOut"`
+	CloseLog       bool        `yaml:"CloseLog"`
+	CloseWebLog    bool        `yaml:"CloseWebLog"`
+}
+
+// HttpsConfig 代表HTTPS相关配置的结构体
+type HttpsConfig struct {
+	IsEnable    bool   `yaml:"IsEnable"`
+	HttpsListen string `yaml:"HttpsListen"`
+	PemPath     string `yaml:"PemPath"`
+	KeyPath     string `yaml:"KeyPath"`
+}

+ 32 - 2
go.mod

@@ -1,10 +1,40 @@
-module rpc
+module JsRpc
 
-go 1.20
+go 1.22.1
 
 require (
 	github.com/gin-gonic/gin v1.9.1
 	github.com/gorilla/websocket v1.5.1
 	github.com/sirupsen/logrus v1.9.3
 	github.com/unrolled/secure v1.14.0
+	github.com/weberhong/figlet4go v0.0.0-20160909034824-bc879344e874
+	gopkg.in/yaml.v3 v3.0.1
+)
+
+require (
+	github.com/bytedance/sonic v1.9.1 // indirect
+	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
+	github.com/fatih/color v1.16.0 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
+	github.com/gin-contrib/sse v0.1.0 // indirect
+	github.com/go-playground/locales v0.14.1 // indirect
+	github.com/go-playground/universal-translator v0.18.1 // indirect
+	github.com/go-playground/validator/v10 v10.14.0 // indirect
+	github.com/goccy/go-json v0.10.2 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
+	github.com/leodido/go-urn v1.2.4 // indirect
+	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-isatty v0.0.20 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
+	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+	github.com/ugorji/go/codec v1.2.11 // indirect
+	golang.org/x/arch v0.3.0 // indirect
+	golang.org/x/crypto v0.14.0 // indirect
+	golang.org/x/net v0.17.0 // indirect
+	golang.org/x/sys v0.14.0 // indirect
+	golang.org/x/text v0.13.0 // indirect
+	google.golang.org/protobuf v1.30.0 // indirect
 )

+ 88 - 47
go.sum

@@ -1,60 +1,101 @@
+github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
+github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
+github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
+github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
+github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
+github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
+github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
 github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
 github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
-github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
-github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
-github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
-github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
-github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
-github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
-github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
-github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
-github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
-github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
-github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
-github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
+github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
+github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
+github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
+github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
+github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
+github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
-github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
-github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
-github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
-github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
-github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
-github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
-github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
+github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
+github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
+github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
+github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
-github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
-github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
+github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
+github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
-github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
-github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
-github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
-github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
-github.com/unrolled/secure v1.0.9 h1:BWRuEb1vDrBFFDdbCnKkof3gZ35I/bnHGyt0LB0TNyQ=
-github.com/unrolled/secure v1.0.9/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI=
-github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
-github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
+github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
+github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
+github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
+github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/unrolled/secure v1.14.0 h1:u9vJTU/pR4Bny0ntLUMxdfLtmIRGvQf2sEFuA0TG9AE=
+github.com/unrolled/secure v1.14.0/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40=
+github.com/weberhong/figlet4go v0.0.0-20160909034824-bc879344e874 h1:pKoR9yFIrYsX/dvBF5FDjlmHrSAVJp9y5pDWauJn4uI=
+github.com/weberhong/figlet4go v0.0.0-20160909034824-bc879344e874/go.mod h1:so6/8uteu8X0r6SpBU9CyyjXQAXt2Zh6tkLE/l2QIKQ=
+golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
+golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
+golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
+golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
+golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
+golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
+golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
+google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 157 - 87
main.go

@@ -1,47 +1,52 @@
 package main
 
 import (
+	"JsRpc/config"
 	"encoding/json"
 	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/gorilla/websocket"
 	log "github.com/sirupsen/logrus"
 	"github.com/unrolled/secure"
+	"math/rand"
 	"net/http"
-	"os"
+	"strconv"
 	"strings"
 	"sync"
 	"time"
 )
 
 var (
-	// BasicPort The original port without SSL certificate
-	BasicPort = `:12080`
-	// SSLPort "Secure" port with SSL certificate
-	SSLPort = `:12443`
-	// websocket.Upgrader specifies parameters for upgrading an HTTP connection to a
-	// WebSocket connection.
 	upGrader = websocket.Upgrader{
 		CheckOrigin: func(r *http.Request) bool { return true },
 	}
-	hlSyncMap sync.Map
-	gm        = &sync.Mutex{}
-	// 默认超时时间,没有得到数据的超时时间 单位:秒
+	hlSyncMap      sync.Map
+	gm             = &sync.Mutex{}
 	defaultTimeout = 30
-	isPrint        = false
+	isPrint        = true
 )
 
+// Clients 客户端信息
 type Clients struct {
 	clientGroup string
-	clientName  string
+	clientId    string
 	actionData  map[string]chan string
 	clientWs    *websocket.Conn
 }
 
+// Message 请求和传递请求
 type Message struct {
 	Action string `json:"action"`
 	Param  string `json:"param"`
 }
+
+type ApiParam struct {
+	GroupName string `form:"group" json:"group"`
+	ClientId  string `form:"clientId" json:"clientId"`
+	Action    string `form:"action" json:"action"`
+	Param     string `form:"param" json:"param"`
+}
+
 type logWriter struct{}
 
 func (w logWriter) Write(p []byte) (n int, err error) {
@@ -56,28 +61,39 @@ func logPrint(p ...interface{}) {
 }
 
 // NewClient  initializes a new Clients instance
-func NewClient(group string, name string, ws *websocket.Conn) *Clients {
+func NewClient(group string, uid string, ws *websocket.Conn) *Clients {
 	return &Clients{
 		clientGroup: group,
-		clientName:  name,
+		clientId:    uid,
 		actionData:  make(map[string]chan string, 1), // action有消息后就保存到chan里
 		clientWs:    ws,
 	}
 }
+func GinJsonMsg(c *gin.Context, code int, msg string) {
+	c.JSON(code, gin.H{"status": code, "data": msg})
+	return
+}
 
 // ws, provides inject function for a job
 func ws(c *gin.Context) {
-	group, name := c.Query("group"), c.Query("name")
-	if group == "" || name == "" {
+	group, clientId := c.Query("group"), c.Query("clientId")
+	//必须要group名字,不然不让它连接ws
+	if group == "" {
 		return
 	}
+	//没有给客户端id的话 就用时间戳给他生成一个
+	if clientId == "" {
+		millisId := time.Now().UnixNano() / int64(time.Millisecond)
+		clientId = fmt.Sprintf("%d", millisId)
+	}
 	wsClient, err := upGrader.Upgrade(c.Writer, c.Request, nil)
 	if err != nil {
-		fmt.Println("websocket err:", err)
+		log.Error("websocket err:", err)
 		return
 	}
-	client := NewClient(group, name, wsClient)
-	hlSyncMap.Store(group+"->"+name, client)
+	client := NewClient(group, clientId, wsClient)
+	hlSyncMap.Store(group+"->"+clientId, client)
+	logPrint("新上线group:" + group + ",clientId:->" + clientId)
 	for {
 		//等待数据
 		_, message, err := wsClient.ReadMessage()
@@ -91,18 +107,17 @@ func ws(c *gin.Context) {
 			action := msg[:strIndex]
 			client.actionData[action] <- msg[strIndex+5:]
 			logPrint("get_message:", msg[strIndex+5:])
-			//hlSyncMap.Store(group+"->"+name, client)
 		} else {
-			fmt.Println(msg, "message error")
+			log.Error(msg, "message error")
 		}
 
 	}
 	defer func(ws *websocket.Conn) {
 		_ = ws.Close()
-		logPrint(group+"->"+name, "下线了")
+		logPrint(group+"->"+clientId, "下线了")
 		hlSyncMap.Range(func(key, value interface{}) bool {
 			//client, _ := value.(*Clients)
-			if key == group+"->"+name {
+			if key == group+"->"+clientId {
 				hlSyncMap.Delete(key)
 			}
 			return true
@@ -120,13 +135,14 @@ func wsTest(c *gin.Context) {
 		}
 		msg := string(message)
 		logPrint("接收到测试消息", msg)
-		_ = testClient.WriteMessage(1, []byte(msg))
+		_ = testClient.WriteMessage(websocket.BinaryMessage, []byte(msg))
 	}
 	defer func(ws *websocket.Conn) {
 		_ = ws.Close()
 	}(testClient)
 }
 
+// GQueryFunc 发送请求到客户端
 func GQueryFunc(client *Clients, funcName string, param string, resChan chan<- string) {
 	WriteDate := Message{}
 	WriteDate.Action = funcName
@@ -165,53 +181,66 @@ func GQueryFunc(client *Clients, funcName string, param string, resChan chan<- s
 	}()
 }
 
-func ResultSet(c *gin.Context) {
-	var getGroup, getName, Action, Param string
-
-	//获取参数
-	getGroup, getName, Action, Param = c.Query("group"), c.Query("name"), c.Query("action"), c.Query("param")
-	//如果获取不到 说明是post提交的
-	if getGroup == "" && getName == "" {
-		//切换post获取方式
-		getGroup, getName, Action, Param = c.PostForm("group"), c.PostForm("name"), c.PostForm("action"), c.PostForm("param")
-	}
-
-	if getGroup == "" || getName == "" {
-		c.JSON(400, gin.H{"status": 400, "data": "input group and name"})
+// GetResult 接收web请求参数,并发给客户端获取结果
+func GetResult(c *gin.Context) {
+	var RequestParam ApiParam
+	if err := c.ShouldBind(&RequestParam); err != nil {
+		GinJsonMsg(c, http.StatusBadRequest, err.Error())
 		return
 	}
-	clientName, ok := hlSyncMap.Load(getGroup + "->" + getName)
-	if ok == false {
-		c.JSON(400, gin.H{"status": 400, "data": "注入了ws?没有找到当前组和名字"})
-		return
+
+	group := RequestParam.GroupName
+	if group == "" {
+		GinJsonMsg(c, http.StatusBadRequest, "需要传入group")
 	}
-	if Action == "" {
-		c.JSON(200, gin.H{"group": getGroup, "name": getName})
+	groupClients := make(map[string]*Clients)
+	//循环读取syncMap 获取group名字的
+	hlSyncMap.Range(func(key, value interface{}) bool {
+		k := key.(string)
+		if strings.HasPrefix(k, group+"->") {
+			client := value.(*Clients)
+			groupClients[k] = client
+		}
+		return true
+	})
+	if len(groupClients) == 0 {
+		GinJsonMsg(c, http.StatusBadRequest, "没有找到注入的group:"+group)
 		return
 	}
-	//取一个ws客户端
-	client, ko := clientName.(*Clients)
-	if !ko {
+	action := RequestParam.Action
+	if action == "" {
+		GinJsonMsg(c, http.StatusOK, "请传入action来调用客户端方法")
 		return
 	}
+	clientId := RequestParam.ClientId
+	var client *Clients
+	// 不传递clientId时候,从group分组随便拿一个
+	if clientId == "" {
+		groupKeys := make([]string, 0, len(groupClients))
+		for k := range groupClients {
+			groupKeys = append(groupKeys, k)
+		}
+		// 使用随机数发生器
+		r := rand.New(rand.NewSource(time.Now().UnixNano()))
+		randomIndex := r.Intn(len(groupKeys)) // 随机拿一个group开头的
+		clientName := groupKeys[randomIndex]  // group->clientId
+		client = groupClients[clientName]
 
-	c2 := make(chan string, 1)
-	go GQueryFunc(client, Action, Param, c2)
-	//把管道传过去,获得值就返回了
-	c.JSON(200, gin.H{"status": 200, "group": client.clientGroup, "name": client.clientName, "data": <-c2})
-
-}
-
-func checkTimeout(c2 chan string) {
-	// 100ms检查一次
-	for i := 0; i < defaultTimeout*10; i++ {
-		if len(c2) > 0 {
+	} else {
+		clientName, ok := hlSyncMap.Load(group + "->" + clientId)
+		if ok == false {
+			GinJsonMsg(c, http.StatusBadRequest, "没有找到group,clientId:"+group+"->"+clientId)
 			return
 		}
-		time.Sleep(time.Millisecond * 100)
+		//取一个ws客户端
+		client, _ = clientName.(*Clients)
+
 	}
-	// 循环完了还是没有数据,那就超时退出
-	c2 <- "黑脸怪:timeout"
+	c2 := make(chan string, 1)
+	go GQueryFunc(client, action, RequestParam.Param, c2)
+	//把管道传过去,获得值就返回了
+	c.JSON(http.StatusOK, gin.H{"status": 200, "group": client.clientGroup, "clientId": client.clientId, "data": <-c2})
+
 }
 
 func Execjs(c *gin.Context) {
@@ -242,28 +271,29 @@ func Execjs(c *gin.Context) {
 
 	c2 := make(chan string)
 	go GQueryFunc(client, Action, JsCode, c2)
-	c.JSON(200, gin.H{"status": "200", "group": client.clientGroup, "name": client.clientName, "data": <-c2})
+	c.JSON(200, gin.H{"status": "200", "group": client.clientGroup, "name": client.clientId, "data": <-c2})
 
 }
 
-func getList(c *gin.Context) {
-	resList := "黑脸怪:\r\n\t"
-	hlSyncMap.Range(func(key, value interface{}) bool {
-		resList += key.(string) + "\r\n\t"
+func GetList(c *gin.Context) {
+	var groupMap []string
+	hlSyncMap.Range(func(key, _ interface{}) bool {
+		k := key.(string)
+		groupMap = append(groupMap, k)
 		return true
 	})
-	c.String(200, resList)
+	c.JSON(http.StatusOK, gin.H{"status": 200, "data": groupMap})
 }
 
 func Index(c *gin.Context) {
 	c.String(200, "你好,我是黑脸怪~")
 }
 
-func TlsHandler() gin.HandlerFunc {
+func TlsHandler(HttpsHost string) gin.HandlerFunc {
 	return func(c *gin.Context) {
 		secureMiddleware := secure.New(secure.Options{
 			SSLRedirect: true,
-			SSLHost:     SSLPort,
+			SSLHost:     HttpsHost,
 		})
 		err := secureMiddleware.Process(c.Writer, c.Request)
 		if err != nil {
@@ -274,33 +304,73 @@ func TlsHandler() gin.HandlerFunc {
 	}
 }
 func main() {
-	for _, v := range os.Args {
-		if v == "log" {
-			isPrint = true
-		}
+	JsRpc := "       __       _______..______      .______     ______ \n      |  |     /       ||   _  \\     |   _  \\   /      |\n      |  |    |   (----`|  |_)  |    |  |_)  | |  ,----'\n.--.  |  |     \\   \\    |      /     |   ___/  |  |     \n|  `--'  | .----)   |   |  |\\  \\----.|  |      |  `----.\n \\______/  |_______/    | _| `._____|| _|       \\______|\n                                                        \n"
+	fmt.Print(JsRpc)
+
+	log.SetFormatter(&log.TextFormatter{
+		ForceColors:     true, // 强制终端输出带颜色日志
+		FullTimestamp:   true, // 显示完整时间戳
+		TimestampFormat: "2006-01-02 15:04:05",
+	})
+	ConfigPath := "./config.yaml"
+	MainConf := config.ConfStruct{
+		BasicListen: `:12080`,
+		HttpsServices: config.HttpsConfig{
+			IsEnable:    false,
+			HttpsListen: `:12443`,
+		},
+		DefaultTimeOut: defaultTimeout,
+	}
+	_ = config.InitConf(ConfigPath, &MainConf)
+
+	if MainConf.CloseWebLog {
+		// 将默认的日志输出器设置为空
+		gin.DefaultWriter = logWriter{}
 	}
-	// 将默认的日志输出器设置为空
-	//gin.DefaultWriter = logWriter{}
-	fmt.Println("欢迎使用jsrpc~")
+	if MainConf.CloseLog {
+		isPrint = false
+	}
+	defaultTimeout = MainConf.DefaultTimeOut
+
 	gin.SetMode(gin.ReleaseMode)
 	r := gin.Default()
 	r.GET("/", Index)
-	r.GET("/go", ResultSet)
-	r.POST("/go", ResultSet)
+	r.GET("/go", GetResult)
+	r.POST("/go", GetResult)
 	r.GET("/ws", ws)
 	r.GET("/wst", wsTest)
 	r.GET("/execjs", Execjs)
 	r.POST("/execjs", Execjs)
-	r.GET("/list", getList)
-	r.Use(TlsHandler())
+	r.GET("/list", GetList)
+	if MainConf.HttpsServices.IsEnable {
+		r.Use(TlsHandler(MainConf.HttpsServices.HttpsListen))
+		go func() {
+			err := r.RunTLS(
+				MainConf.HttpsServices.HttpsListen,
+				MainConf.HttpsServices.PemPath,
+				MainConf.HttpsServices.KeyPath,
+			)
+			if err != nil {
+				log.Error(err)
+			}
+		}()
 
-	//编译https版放开下面这行注释代码
-	//go func() {
-	//	err := r.RunTLS(SSLPort, "zhengshu.pem", "zhengshu.key")
-	//	if err != nil {
-	//		fmt.Println(err)
-	//	}
-	//}()
-	_ = r.Run(BasicPort)
+	}
+	var sb strings.Builder
+	sb.WriteString("当前监听地址:")
+	sb.WriteString(MainConf.BasicListen)
+
+	sb.WriteString(" tls启用状态:")
+	sb.WriteString(strconv.FormatBool(MainConf.HttpsServices.IsEnable))
+
+	if MainConf.HttpsServices.IsEnable {
+		sb.WriteString(" https监听地址:")
+		sb.WriteString(MainConf.HttpsServices.HttpsListen)
+	}
+	log.Infoln(sb.String())
 
+	err := r.Run(MainConf.BasicListen)
+	if err != nil {
+		log.Error(err)
+	}
 }

+ 0 - 118
resouces/JsEnv.js

@@ -1,118 +0,0 @@
-function Hlclient(wsURL) {
-    this.wsURL = wsURL;
-    this.handlers = {
-        _execjs: function (resolve, param) {
-            var res = eval(param)
-            if (!res) {
-                resolve("没有返回值")
-            } else {
-                resolve(res)
-            }
-
-        }
-    };
-    this.socket = {};
-    if (!wsURL) {
-        throw new Error('wsURL can not be empty!!')
-    }
-    this.connect()
-    this.socket["ySocket"].addEventListener('close', (event) => {
-        console.log('rpc已关闭');
-    });
-}
-
-Hlclient.prototype.connect = function () {
-    console.log('begin of connect to wsURL: ' + this.wsURL);
-    var _this = this;
-    try {
-        this.socket["ySocket"] = new WebSocket(this.wsURL);
-        this.socket["ySocket"].onmessage = function (e) {
-            try {
-                let blob = e.data
-                blob.text().then(data => {
-                    _this.handlerRequest(data);
-                })
-            } catch {
-                console.log("not blob")
-                _this.handlerRequest(blob)
-            }
-
-        }
-    } catch (e) {
-        console.log("connection failed,reconnect after 10s");
-        setTimeout(function () {
-            _this.connect()
-        }, 10000)
-    }
-    this.socket["ySocket"].onclose = function () {
-        console.log("connection failed,reconnect after 10s");
-        setTimeout(function () {
-            _this.connect()
-        }, 10000)
-    }
-    this.socket["ySocket"].addEventListener('open', (event) => {
-        console.log("rpc连接成功");
-    });
-    this.socket["ySocket"].addEventListener('error', (event) => {
-        console.error('rpc连接出错,请检查是否打开服务端:', event.error);
-    });
-
-};
-Hlclient.prototype.send = function (msg) {
-    this.socket["ySocket"].send(msg)
-}
-
-Hlclient.prototype.regAction = function (func_name, func) {
-    if (typeof func_name !== 'string') {
-        throw new Error("an func_name must be string");
-    }
-    if (typeof func !== 'function') {
-        throw new Error("must be function");
-    }
-    console.log("register func_name: " + func_name);
-    this.handlers[func_name] = func;
-    return true
-
-}
-
-//收到消息后这里处理,
-Hlclient.prototype.handlerRequest = function (requestJson) {
-    var _this = this;
-    var result = JSON.parse(requestJson);
-    //console.log(result)
-    if (!result['action']) {
-        this.sendResult('', 'need request param {action}');
-        return
-    }
-    var action = result["action"]
-    var theHandler = this.handlers[action];
-    if (!theHandler) {
-        this.sendResult(action, 'action not found');
-        return
-    }
-    try {
-        if (!result["param"]) {
-            theHandler(function (response) {
-                _this.sendResult(action, response);
-            })
-        } else {
-            var param = result["param"]
-            try {
-                param = JSON.parse(param)
-            } catch (e) {
-                console.log("")
-            }
-            theHandler(function (response) {
-                _this.sendResult(action, response);
-            }, param)
-        }
-
-    } catch (e) {
-        console.log("error: " + e);
-        _this.sendResult(action , e);
-    }
-}
-
-Hlclient.prototype.sendResult = function (action, e) {
-    this.send(action + atob("aGxeX14") + e);
-}

+ 25 - 31
resouces/JsEnv_Dev.js

@@ -11,32 +11,20 @@ function Hlclient(wsURL) {
 
         }
     };
-    this.socket = {};
+    this.socket = undefined;
     if (!wsURL) {
         throw new Error('wsURL can not be empty!!')
     }
     this.connect()
-    this.socket["ySocket"].addEventListener('close', (event) => {
-        console.log('rpc已关闭');
-    });
 }
 
 Hlclient.prototype.connect = function () {
     console.log('begin of connect to wsURL: ' + this.wsURL);
     var _this = this;
     try {
-        this.socket["ySocket"] = new WebSocket(this.wsURL);
-        this.socket["ySocket"].onmessage = function (e) {
+        this.socket = new WebSocket(this.wsURL);
+        this.socket.onmessage = function (e) {
             _this.handlerRequest(e.data)
-            // let blob = e.data
-            // try {
-            //     blob.text().then(data => {
-            //         _this.handlerRequest(data);
-            //     })
-            // } catch {
-            //     console.log("not blob")
-            //     _this.handlerRequest(blob)
-            // }
         }
     } catch (e) {
         console.log("connection failed,reconnect after 10s");
@@ -44,22 +32,22 @@ Hlclient.prototype.connect = function () {
             _this.connect()
         }, 10000)
     }
-    this.socket["ySocket"].onclose = function () {
-        console.log("connection failed,reconnect after 10s");
+    this.socket.onclose = function () {
+        console.log('rpc已关闭');
         setTimeout(function () {
             _this.connect()
         }, 10000)
     }
-    this.socket["ySocket"].addEventListener('open', (event) => {
+    this.socket.addEventListener('open', (event) => {
         console.log("rpc连接成功");
     });
-    this.socket["ySocket"].addEventListener('error', (event) => {
+    this.socket.addEventListener('error', (event) => {
         console.error('rpc连接出错,请检查是否打开服务端:', event.error);
     });
 
 };
 Hlclient.prototype.send = function (msg) {
-    this.socket["ySocket"].send(msg)
+    this.socket.send(msg)
 }
 
 Hlclient.prototype.regAction = function (func_name, func) {
@@ -100,17 +88,17 @@ Hlclient.prototype.handlerRequest = function (requestJson) {
             theHandler(function (response) {
                 _this.sendResult(action, response);
             })
-        } else {
-            var param = result["param"]
-            try {
-                param = JSON.parse(param)
-            } catch (e) {
-                console.log("")
-            }
-            theHandler(function (response) {
-                _this.sendResult(action, response);
-            }, param)
+            return
+        }
+        var param = result["param"]
+        try {
+            param = JSON.parse(param)
+        } catch (e) {
+            console.log("")//不是json无需操作
         }
+        theHandler(function (response) {
+            _this.sendResult(action, response);
+        }, param)
 
     } catch (e) {
         console.log("error: " + e);
@@ -119,10 +107,16 @@ Hlclient.prototype.handlerRequest = function (requestJson) {
 }
 
 Hlclient.prototype.sendResult = function (action, e) {
+    if (typeof e === 'object' && e !== null) {
+        try {
+            e = JSON.stringify(e)
+        } catch (v) {
+            console.log(v)//不是json无需操作
+        }
+    }
     this.send(action + atob("aGxeX14") + e);
 }
 
-
 function transjson(formdata) {
     var regex = /"action":(?<actionName>.*?),/g
     var actionName = regex.exec(formdata).groups.actionName