在macOS上的SSH远程时,使用Terminal或iTerm2做客户端时,可以自动回车完成登录了。

pull/130/head
Apex Liu 2018-11-11 06:10:35 +08:00
parent 73051854dd
commit a883f8a80b
41 changed files with 1299 additions and 712 deletions

23
client/cfg/cacert.cer Normal file
View File

@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIID4TCCAsmgAwIBAgIBADANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJDTjEN
MAsGA1UECgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcGA1UE
AwwQVFA0QSBUZWxlcG9ydCBDQTAgFw0xODExMDgxNzMyMjJaGA8yMTE4MTAxNTE3
MzIyMlowUjELMAkGA1UEBhMCQ04xDTALBgNVBAoMBFRQNEExGTAXBgNVBAsMEFRQ
NEEgVGVsZXBvcnQgQ0ExGTAXBgNVBAMMEFRQNEEgVGVsZXBvcnQgQ0EwggEiMA0G
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCml/ERetMxXh17Uf4IlLjDfgGwnpQZ
L0UoCO2vAHk0h4eRx5x4fMB/Ml1YHYghVKJ9rxWeb+v5wWz9a8CFtNu+s46nG9cw
XdneQ2UT4L5+7a+mOyNGAcascfLWfUYoMnF0ugIf3OfsUeAwinMnvKi2I2b8XdXH
cXRqToEYmcovPLKaXByXFLjcMHMRwR5Es0zIRx+4uuIvCICndLRX5IGy/HGEPZyV
Vtrrrvkngz54UHB3C3sKuHuHBOxvJ1grJV9fLFptsbPhMonXfYKJpf+ODwmkEDFS
+4vV61ctYvUiElCPeQte23v6lIujqoLoHzYoi8J5BxEwBggeCgAZ/YYFAgMBAAGj
gb8wgbwwHQYDVR0OBBYEFKHqO88fYp8ard6SKPi8X4Gpr+uiMHoGA1UdIwRzMHGA
FKHqO88fYp8ard6SKPi8X4Gpr+uioVakVDBSMQswCQYDVQQGEwJDTjENMAsGA1UE
CgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcGA1UEAwwQVFA0
QSBUZWxlcG9ydCBDQYIBADAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB
BjANBgkqhkiG9w0BAQsFAAOCAQEAQWYR/WBsaWEwTE9IuoULsGs0G5CWwfIvezil
HUmtQQb2G3P0kxv43xU3PT3czfbd22h9diSHyyYXOShHIfNx7ZD4SUMGyukcfPst
oyLcnlMK2hxtu3s5hTc76D+m7ylLQgV52jwHOXXS9toRhIo76HY6Q5Qbz9koP/x+
MOwmNJ+dLQj/qI1WZZI7FS7Idi2dB5KMp11a2kxgeBIxwkCreBm/MLfdLRyaMdGX
1L05AI0d7lCu+N+Fu2QX9wToBZ4rRQFrdakgCXqXCdM1O4Akf1KvCDXHUJKgMQUE
Hav+XOE7nrtxIwfH4VjmCZYRE+8ZTYbG8xSHDwIRMxhsLnb63w==
-----END CERTIFICATE-----

28
client/cfg/localhost.key Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDxI1ZDRvuNnkVB
JgTZmnwF97d7Ace+R0gSSkWi2l2oezakLSdUUkiysr1wx45u2Du36FNqMGg7LiCZ
SX1e2Zba96PI6vwNGnlprCfXTe2eV3W8kMPKA6c9X8BTktMZINNHO3K591jGx+uM
fyrl6/CFVPHNkl73Ium9u91JXIX9BOata4RTlphmHADc+hPXuC6oeN8qayZvV2rV
Jfx1wMlWCMiGJM36JJO5pywteBCKQkVJuJ7y29XF2wT690o+i6ugk+yI2/2OpiET
2E5SYdvyhlbcU+iBERsnY3X7IvFY8/m00YIjIc3reGSEwt9M5WTPRCjgonnpQGAx
9xWXwqkzAgMBAAECggEAT9b2YdInye0EWxy+cFoBBGzPeE/PlcW+LCghRFlutzEM
l3FH21hfL6OUq7m3BCZeJ3cp3zfl2upb6sT1WKlMlHV36jc7ew8v8fgJPPVVXp7w
oZ2A5estvVltsX4knOZMbgJV6xLldvOMnvkf9/6VpV/Jq9nxzXvmzmZcT0TuLCaF
uPk/g/yD5qQ8LkWXDVJeBiDrrOZYo5F+T8bveYKKIEZV0ZAlXwJqVOUFnhffIaDF
fZVDOv4K3+q0aRDLTY2hxptHZiKzpLXgU634nBN3fiy0Fj88upNIus22gjaz+Jfx
2pYv22iGNXAMFQwGaeuT7d4+qhgxze8C7YlLJsJWCQKBgQD8kkXbgYG+8NoKmovz
ki9nuK1R6On5pNjZ344SJm6t/s4FaxQhE/4oHvODwgolqKyT2Sq1K8/5NInRGA29
xPqqkkhwWk3Zf9VTXgmuXsOikPhbCOuiehO+6/ZthmHYy1jBMqkAIWYaL9Ytn2qb
dKMHwzNdnppQNdQnwmXI2ZdRBQKBgQD0aVTSOmKfKdIxH9qFLdbi2CoyJMzjAjm9
Ss5M0OhI9wZnCXyjPBx4hOs+M/BKx4lQ296u2Dh+gSK3L8K3x8lVqqx8gd614qaC
EWzXZpAbd1S835o2vVYEWXU0iI9s0jkj+VnILEWBMRPYManRUATB2phwRPulimdu
o+BWN0GG1wKBgCYBxO1hMasQB1+tHf5LM0MCcWJwEDV27wLqNzDYA7O/MjVyhZbs
sURMVAyxuGEuXrno5hpZO3SeyVZjrj2uVKIyXSA7FpfyOqHO9tn8fKgL9LOORhcv
E6WZUH3uyO6cuwBnpTLV082BAVPgN2SpSpcycppV8Za8Yu6QvExbIgAZAoGBALcq
ANETxDj3hHggIQlRkwqpaOXvQkSVtGOxne1fWdTkmz24lFlYgRWotwsErX29D6Ez
RSzPCXd0m2mhN1G3PaEfqOgeA6NXWeV73Y+HY1PSGAT7pXyEY+QajoVyGdo5qWzW
P3yOAQCSoQaSIWulhgspILhyWgxzLpRx53t1KXw9AoGBAOxsrIrx/S6onTz58ncZ
m99OWwJX4WmY5KKhc5dWrfgHrNfldSbhjRhjALy6hSPzkaVy01wXKeeIZl64rUbd
S/r58yALQ5wuIHAi53BLStxgqEdHQHLg16GqL3b/+Waaf+Fy9y5eoUQ976HPr33G
uDJ1AAnWjX3KvcyZeWLFTU2/
-----END PRIVATE KEY-----

24
client/cfg/localhost.pem Normal file
View File

@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEGTCCAwGgAwIBAgIEASUKPDANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJD
TjENMAsGA1UECgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcG
A1UEAwwQVFA0QSBUZWxlcG9ydCBDQTAgFw0xODExMDgxNzMyMjdaGA8yMTE4MTAx
NTE3MzIyN1owXzELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkJKMQswCQYDVQQHDAJ0
cDERMA8GA1UECgwIVGVsZXBvcnQxDzANBgNVBAsMBkFzc2lzdDESMBAGA1UEAwwJ
bG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8SNWQ0b7
jZ5FQSYE2Zp8Bfe3ewHHvkdIEkpFotpdqHs2pC0nVFJIsrK9cMeObtg7t+hTajBo
Oy4gmUl9XtmW2vejyOr8DRp5aawn103tnld1vJDDygOnPV/AU5LTGSDTRztyufdY
xsfrjH8q5evwhVTxzZJe9yLpvbvdSVyF/QTmrWuEU5aYZhwA3PoT17guqHjfKmsm
b1dq1SX8dcDJVgjIhiTN+iSTuacsLXgQikJFSbie8tvVxdsE+vdKPouroJPsiNv9
jqYhE9hOUmHb8oZW3FPogREbJ2N1+yLxWPP5tNGCIyHN63hkhMLfTOVkz0Qo4KJ5
6UBgMfcVl8KpMwIDAQABo4HnMIHkMB0GA1UdDgQWBBRc5d0h39QISTM55kCqPyy1
dohEHTB6BgNVHSMEczBxgBSh6jvPH2KfGq3ekij4vF+Bqa/roqFWpFQwUjELMAkG
A1UEBhMCQ04xDTALBgNVBAoMBFRQNEExGTAXBgNVBAsMEFRQNEEgVGVsZXBvcnQg
Q0ExGTAXBgNVBAMMEFRQNEEgVGVsZXBvcnQgQ0GCAQAwDAYDVR0TAQH/BAIwADAO
BgNVHQ8BAf8EBAMCA4gwEwYDVR0lBAwwCgYIKwYBBQUHAwEwFAYDVR0RBA0wC4IJ
bG9jYWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQAfj/CpFDhv5CrnN2kxhtRAmesJ
q6/KxxkBaimjbS/BpfvqfC9RxGH7MIqGUkbC4/ADkEt2OmVU4+f2R3+rCl+x+r1t
9+3r/JSYYVBxFnF1GbDhiY9sKahgb4HoFjE2Fj8eVODcEzdApLr198p5IIIyfBys
WHV4CYFMvq5qCKbSR/JMfrm9GArAh1J+B+JMIfm8xwerFi0tfK2YT+N4QkvbidjG
sd+RKlR51GHo9m4iEQ7mDd9H8joVrVs2MVLGf2EoVU5y/Ahee4g7k3SKrn3GI/Ec
6BRCht+INCLI3bnC3MtJHJRzv5Vmu4pSh3cwnVHfe+VWLGvGlp2+KeC02xZ2
-----END CERTIFICATE-----

View File

@ -0,0 +1,106 @@
{
"file_version": 3,
"ssh": {
"selected": "terminal",
"available": [
{
"name":"terminal",
"display": "终端(系统自带)",
"app": "Terminal.app",
"cmdline": "Basic",
"desc": []
},
{
"name": "iterm2",
"display": "iTerm2",
"app": "iTerm2.app",
"cmdline": "Default",
"desc": []
},
{
"name": "securecrt",
"display": "SecureCRT",
"app": "SecureCRT.app",
"cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip}",
"desc": []
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": "",
"desc": []
}
]
},
"sftp": {
"selected": "securefx",
"available": [
{
"name": "securefx",
"display": "SecureFX",
"app": "SecureCRT.app",
"cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip}",
"desc": []
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": "",
"desc": []
}
]
},
"telnet": {
"selected": "terminal",
"available": [
{
"name":"terminal",
"display": "终端(系统自带)",
"app": "Terminal.app",
"cmdline": "Basic",
"desc": []
},
{
"name": "iterm2",
"display": "iTerm2",
"app": "iTerm2.app",
"cmdline": "Default",
"desc": []
},
{
"name": "securecrt",
"display": "SecureCRT",
"app": "SecureCRT.app",
"cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip}",
"desc": []
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": "",
"desc": []
}
]
},
"rdp": {
"selected": "freerdp",
"available": [
{
"name": "FreeRDP",
"display": "FreeRDP",
"app": "",
"cmdline": "",
"desc": [
"建议使用homebrew安装freerdp安装后freerdp默认路径在/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp",
"首次安装freerdp后需要重新启动计算机"
]
}
]
}
}

View File

@ -0,0 +1,82 @@
{
"ssh": {
"selected": "putty",
"available": [
{
"name":"putty",
"display": "PuTTY内置",
"app": "{assist_tools_path}\\putty\\putty.exe",
"cmdline": "-ssh -pw **** -P {host_port} -l {user_name} {host_ip}"
},
{
"name": "crt",
"display": "SecureCRT",
"app": "",
"cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip}"
},
{
"name": "xshell",
"display": "Xshell",
"app": "",
"cmdline": "-newtab \"TP#ssh://{real_ip}\" -url ssh://{user_name}:****@{host_ip}:{host_port}"
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": ""
}
]
},
"scp": {
"selected": "winscp",
"available": [
{
"name":"winscp",
"display": "WinSCP内置",
"app": "{assist_tools_path}\\winscp\\winscp.exe",
"cmdline": "/sessionname=\"TP#{real_ip}\" {user_name}:****@{host_ip}:{host_port}"
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": ""
}
]
},
"telnet": {
"selected": "putty",
"available": [
{
"name":"putty",
"display": "PuTTY内置",
"app": "{assist_tools_path}\\putty\\putty.exe",
"cmdline": "telnet://{user_name}@{host_ip}:{host_port}"
},
{
"name": "crt",
"display": "SecureCRT",
"app": "",
"cmdline": "/T /N \"TP#telnet://{real_ip}\" /ARG {user_name} /SCRIPT \"{assist_tools_path}\\securecrt-telnet.vbs\" /TELNET {host_ip} {host_port}"
},
{
"name": "other",
"display": "自定义",
"app": "",
"cmdline": ""
}
]
},
"rdp" : {
"available" : [
{
"app" : "{assist_tools_path}\\tprdp\\tprdp-client.exe",
"cmdline" : "/v:{host_ip}:{host_port} /u:{user_name} /t:\"TP#{real_ip}\"",
"display" : "FreeRDP内置",
"name" : "freerdp"
}
],
"selected" : "freerdp"
}
}

View File

@ -4,8 +4,8 @@ PATH_ROOT=$(cd "$(dirname "$0")/.."; pwd)
echo "compiling applescripts for OS X terminal..."
rm ${PATH_ROOT}/src/apple-scpt/Terminal.scpt
rm ${PATH_ROOT}/src/apple-scpt/iTerm2.scpt
rm ${PATH_ROOT}/src/apple-scpt/terminal.scpt
rm ${PATH_ROOT}/src/apple-scpt/iterm2.scpt
osacompile -o ${PATH_ROOT}/src/apple-scpt/Terminal.scpt -x ${PATH_ROOT}/apple-scripts/scripts/Terminal.applescript
osacompile -o ${PATH_ROOT}/src/apple-scpt/iTerm2.scpt -x ${PATH_ROOT}/apple-scripts/scripts/iTerm2.applescript
osacompile -o ${PATH_ROOT}/src/apple-scpt/terminal.scpt -x ${PATH_ROOT}/apple-scripts/scripts/terminal.applescript
osacompile -o ${PATH_ROOT}/src/apple-scpt/iterm2.scpt -x ${PATH_ROOT}/apple-scripts/scripts/iterm2.applescript

View File

@ -1,44 +0,0 @@
on scriptRun(argsCmd, argsProfile, argsTitle)
set theCmd to (argsCmd)
set theProfile to (argsProfile)
set theTitle to (argsTitle)
CommandRun(theCmd, theProfile, theTitle)
end scriptRun
on CommandRun(theCmd, theProfile, theTitle)
tell application "Terminal"
if it is not running then
--if this is the first time Terminal is running you have specify window 1
--if you dont do this you will get two windows and the title wont be set
activate
set newTerm to do script theCmd in window 1
set newTerm's current settings to settings set theProfile
set custom title of front window to theTitle
else
--Terminal is running get the window count
set windowCount to (count every window)
if windowCount = 0 then
--Terminal is running but no windows are open
--run our script in a new window
reopen
activate
do script theCmd in window 1
else
--Terminal is running and we have a window run in a new tab
reopen
activate
tell application "System Events"
tell process "Terminal"
delay 0.2
keystroke "t" using {command down}
end tell
end tell
activate
do script theCmd in front window
end if
set current settings of selected tab of front window to settings set theProfile
set title displays custom title of front window to true
set custom title of selected tab of front window to theTitle
end if
end tell
end CommandRun

View File

@ -0,0 +1,77 @@
on scriptRun(argsCmd, argsProfile, argsTitle)
set theCmd to (argsCmd)
set theProfile to (argsProfile)
set theTitle to (argsTitle)
set useless to "useless"
CommandRun(theCmd, theProfile, theTitle)
end scriptRun
on CommandRun(theCmd, theProfile, theTitle)
tell application "Terminal"
if it is not running then
--if this is the first time Terminal is running you have specify window 1
--if you dont do this you will get two windows and the title wont be set
activate
delay 1.0
set newTerm to do script theCmd in window 1
set newTerm's current settings to settings set theProfile
set custom title of front window to theTitle
delay 1.0
reopen
activate
tell application "System Events" to key code 36
else
--Terminal is running get the window count
set windowCount to (count every window)
if windowCount = 0 then
--Terminal is running but no windows are open
--run our script in a new window
reopen
activate
do script theCmd in window 1
set current settings of selected tab of front window to settings set theProfile
set title displays custom title of front window to true
set custom title of selected tab of front window to theTitle
delay 1.0
reopen
activate
tell application "System Events" to key code 36
else
--Terminal is running and we have a window run in a new tab
reopen
activate
tell application "System Events"
tell process "Terminal"
delay 0.5
keystroke "t" using {command down}
end tell
end tell
reopen
activate
do script theCmd in front window
set current settings of selected tab of front window to settings set theProfile
set title displays custom title of front window to true
set custom title of selected tab of front window to theTitle
delay 1.0
reopen
activate
tell application "System Events" to key code 36
end if
# set current settings of selected tab of front window to settings set theProfile
# set title displays custom title of front window to true
# set custom title of selected tab of front window to theTitle
end if
end tell
end CommandRun

View File

@ -1 +1 @@
@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;font-size:80%;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;font-size:80%;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11,.content .col-sm-12{padding-left:3px;padding-right:3px}.content .arg-detail{font-size:11px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .desc{display:inline-block;margin-top:5px;color:#6b6b6b}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:128px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px}/*# sourceMappingURL=style.css.map */
@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11{padding-left:3px;padding-right:3px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:164px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px}/*# sourceMappingURL=style.css.map */

View File

@ -1 +0,0 @@
{"version":3,"sources":["style.less"],"names":[],"mappings":"AAAA,SAAS,QAaT,KACE,YAJmB,kBAAmB,iCAItC,CACA,cAAA,CACA,qBAAA,CACA,WAGF,KAAM,KACJ,YAGF,QACE,UAAA,CACA,WAAA,CACA,cAAA,CACA,KAAA,CAEA,gBAAA,CAEA,aAAA,CAEA,wBAAA,CACA,UAAA,CACA,YAZF,OAcE,QACE,eAfJ,OAiBE,YACE,gBAAA,CACA,cAIJ,YACE,YAGF,QACE,UAAA,CACA,WAAA,CACA,cAAA,CACA,QAAA,CACA,iBAAA,CACA,gBAAA,CACA,wBAAA,CACA,4BAAA,CACA,aAAA,CACA,YAGF,SACE,qBADF,QAGE,YACE,cAAA,CACA,iBALJ,QAQE,aACE,kBATJ,QAYE,WAZF,QAYa,WAZb,QAYwB,WAZxB,QAYmC,WAZnC,QAY8C,WAZ9C,QAYyD,WAZzD,QAYoE,WAZpE,QAY+E,WAZ/E,QAY0F,WAZ1F,QAYqG,YAZrG,QAYiH,YAZjH,QAY6H,YACzH,gBAAA,CACA,kBAdJ,QAiBE,aACE,eAlBJ,QAiBE,YAEE,IAnBJ,QAiBE,YAEM,IACF,gBApBN,QAwBE,OACE,oBAAA,CACA,cAAA,CACA,cA3BJ,QA8BE,oBAEE,wBAAA,CAEA,iBAAA,CACA,aAnCJ,QAuCE,aACE,mDA7F0D,wBAiG9D,UACE,aAAA,CACA,gBAAA,CACA,mDApG4D,uBAoG5D,CACA,oBAAA,CACA,YAiBF,wBAKE,aAGF,gBAAiB,cAAe,aAE9B,0BAAA,YAGF,aACE,0BAAA,CACA,4BAGF,gBACE,6BAAA,CACA,+BAGF,eAAgB,cAAe,gBAU7B,SAAA,YACA,SAAA,YACA,OAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,aAAA,YACA,kBAGF,cAAc,QAAS,cAAe,eAAc,QAClD,QAAS,OAAT,YACA,uBAAA,YACA,aAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,UAAA,YACA,aAAA,YACA,iBAAA,YACA,iBAAA,YACA,OAAA,YACA,KAAA,YAcF,eACE,cAAA,YACA,gBAAA,YACA,kBAAA,YACA,eAAA,YACA,UAAA,YACA,gBAAA,YAQF,cAEE,UAAA,YACA,cAAA,YACA,oBAAA,YAGF,cACE,iBADF,cACmB,eADnB,cACkC,cAC9B,8BAAA,YAFJ,cAKE,gBACE,UAAA,YANJ,cASE,eACE,UAAA,YAVJ,cAaE,gBACE,SAAA,YACA,SAAA,YACA,OAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,aAAA,YACA,iBAAA,CACA,kBAAA,YAIJ,gBACE,iBADF,gBACmB,eADnB,gBACkC,cAE9B,4BAAA,YAHJ,gBAME,gBAEE,UAAA,YARJ,gBAWE,eAEE,UAAA,YAbJ,gBAgBE,gBACE,kBAAA,YAKJ,wBACE,WAAA,CAEA","file":"style.css","sourceRoot":"../less"}

View File

@ -1,220 +1,225 @@
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TELEPORT助手配置</title>
<link rel="shortcut icon" href="favicon.png">
<link href="plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="plugins/gritter/css/jquery.gritter.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<div class="container">
<span class="title"><i class="fa fa-cog fa-fw"></i> Teleport助手本地配置</span>
<span class="sub-title" id="version"></span>
<span class="sub-title">此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</span>
</div>
<div class="header-fix"></div>
<div class="footer">
<div class="container">
<p><a href="https://tp4a.com/" target="_blank">TELEPORT</a> | &copy;2015 - 2018保留所有权利。</p>
</div>
</div>
<div class="container">
<div class="content">
<div class="arg-detail arg-detail-common">
<p><strong>此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</strong></p>
<span><strong>注意:</strong>命令行参数设置中,可以用以下变量替换(注意大小写!):</span>
<ul>
<li><span class="arg-varb">{host_ip}</span> 替换主机IP地址</li>
<li><span class="arg-varb">{host_port}</span> 替换主机端口号</li>
<li><span class="arg-varb">{user_name}</span> 替换用户名</li>
<li><span class="arg-varb">{real_ip}</span> 替换为远程主机真实IP仅用于显示例如客户端的窗口标题或标签页标题等</li>
</ul>
</div>
<hr/>
<p class="cfg-title">本地 SSH 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="scp-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="scp-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="scp-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="scp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="scp-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="scp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="scp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 SFTP 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="scp-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="scp-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="scp-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="scp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="scp-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="scp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="scp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 TELNET 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="telnet-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="telnet-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地RDP配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="telnet-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="telnet-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地RDP配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="rdp-type" class="col-sm-1 control-label"><strong>RDP客户端</strong></label>
<div class="col-sm-3">
<select id="rdp-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="rdp-app" class="col-sm-1 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-8">
<input id="rdp-app" type="text" class="form-control input-args" />
<span class="desc"><i class="fa fa-info-circle"></i> 建议使用homebrew安装freerdp安装后freerdp默认路径在/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp</span>
<span class="desc"><i class="fa fa-info-circle"></i> 首次安装freerdp后需要重新启动计算机</span>
</div>
</div>
</div>
<hr/>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-sm-1"></div>
<div class="col-sm-3">
<a id="btn-save" class="btn btn-primary" href="javascript:;"><i class="fa fa-check fa-fw"></i> 保存设置</a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="plugins/underscore/underscore-min.js"></script>
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="plugins/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="plugins/gritter/js/jquery.gritter.js"></script>
<script type="text/javascript" src="plugins/keypress/keypress.min.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript">
</script>
</body>
<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8"><![endif]-->
<!--[if !IE]><!-->
<html lang="zh_CN">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>TELEPORT助手配置</title>
<link rel="shortcut icon" href="favicon.png">
<link href="plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="plugins/gritter/css/jquery.gritter.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<div class="container">
<span class="title"><i class="fa fa-cog fa-fw"></i> Teleport 助手本地配置</span>
<span class="sub-title" id="version"></span>
</div>
</div>
<div class="header-fix"></div>
<div class="footer">
<div class="container">
<p><a href="https://tp4a.com/" target="_blank">TELEPORT</a> | &copy;2015 - 2018保留所有权利。</p>
</div>
</div>
<div class="container">
<div class="content">
<div class="arg-detail arg-detail-common">
<p><strong>此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</strong></p>
<span><strong>注意:</strong>命令行参数设置中,可以用以下变量替换(注意大小写!):</span>
<ul>
<li><span class="arg-varb">{host_ip}</span> 替换主机IP地址</li>
<li><span class="arg-varb">{host_port}</span> 替换主机端口号</li>
<li><span class="arg-varb">{user_name}</span> 替换用户名</li>
<li><span class="arg-varb">{real_ip}</span> 替换为远程主机真实IP仅用于显示例如客户端的窗口标题或标签页标题等</li>
<li><span class="arg-varb">{assist_tools_path}</span> 替换为助手工具所在的tools目录的绝对路径</li>
</ul>
</div>
<hr/>
<p class="cfg-title">本地 SSH 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="ssh-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="ssh-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="ssh-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="ssh-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="ssh-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="ssh-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="ssh-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 SFTP 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="sftp-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="sftp-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="sftp-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="sftp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="sftp-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="sftp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="sftp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 TELNET 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="telnet-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="telnet-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 RDP 客户端配置</p>
<!--<div class="arg-detail arg-detail-common">-->
<!--RDP专用命令行参数-->
<!--<ul>-->
<!--<li><span class="arg-varb">{tmp_rdp_file}</span> 替换为助手工具生成的临时配置文件(.rdp的绝对路径用于支持按.rdp配置文件进行连接的RDP客户端</li>-->
<!--<li><span class="arg-varb">{size}</span> [仅FreeRDP] 替换为屏幕尺寸</li>-->
<!--<li><span class="arg-varb">{console}</span> [仅FreeRDP] 替换为是否以Console模式连接</li>-->
<!--<li><span class="arg-varb">{clipboard}</span> [仅FreeRDP] 替换为是否允许剪贴板</li>-->
<!--<li><span class="arg-varb">{drives}</span> [仅FreeRDP] 替换为是否允许映射本地磁盘</li>-->
<!--</ul>-->
<!--</div>-->
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="ssh-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="rdp-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="ssh-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="rdp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="rdp-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="rdp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="rdp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
</div>
</div>
</div>
<hr/>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-sm-2"></div>
<div class="col-sm-6">
<a id="btn-save" class="btn btn-primary" href="javascript:;"><i class="fa fa-check fa-fw"></i> 保存设置!</a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="plugins/underscore/underscore-min.js"></script>
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="plugins/bootstrap/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="plugins/html5shiv/html5shiv.min.js"></script>
<![endif]-->
<!--<script type="text/javascript" src="js/json2.js"></script>-->
<script type="text/javascript" src="plugins/gritter/js/jquery.gritter.js"></script>
<script type="text/javascript" src="plugins/keypress/keypress.min.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript">
</script>
</body>
</html>

View File

@ -5,16 +5,53 @@ var g_url_base = 'http://127.0.0.1:50022';
var g_cfg = null;
var dom = {
term_type: $('#term-type'),
term_profile: $('#term-profile'),
version: $('#version'),
ssh_type: $('#ssh-type'),
ssh_app: $('#ssh-app'),
ssh_cmdline: $('#ssh-cmdline'),
ssh_select_app: $('#ssh-select-app'),
sftp_type: $('#sftp-type'),
sftp_app: $('#sftp-app'),
sftp_cmdline: $('#sftp-cmdline'),
sftp_select_app: $('#sftp-select-app'),
telnet_type: $('#telnet-type'),
telnet_app: $('#telnet-app'),
telnet_cmdline: $('#telnet-cmdline'),
telnet_select_app: $('#telnet-select-app'),
rdp_type: $('#rdp-type'),
rdp_app: $('#rdp-app'),
rdp_cmdline: $('#rdp-cmdline'),
rdp_select_app: $('#rdp-select-app'),
btn_save: $('#btn-save')
};
function get_version() {
$.ajax({
type: 'GET',
timeout: 5000,
url: g_url_base + '/api/get_version',
jsonp: 'callback',
dataType: 'json',
success: function (ret) {
if (ret.code == 0) {
dom.version.text('v' + ret.version);
} else {
alert("获取助手版本信息失败!");
}
},
error: function (jqXhr, _error, _e) {
console.log('state:', jqXhr.state());
alert("获取助手版本信息失败!");
}
});
}
var get_config = function () {
function get_config() {
$.ajax({
type: 'GET',
timeout: 5000,
@ -24,51 +61,122 @@ var get_config = function () {
success: function (ret) {
if (ret.code == 0) {
g_cfg = ret.data;
console.log(g_cfg);
update_dom();
} else {
notify_error("获取配置信息失败!");
alert("获取配置信息失败!");
}
},
error: function (jqXhr, _error, _e) {
console.log('state:', jqXhr.state());
notify_error("获取配置信息失败!");
alert("获取配置信息失败!");
}
});
}
function update_dom() {
console.log('---', g_cfg);
if (_.isNull(g_cfg))
return;
dom.term_type.html('');
if (!_.isUndefined(g_cfg.term)) {
if (_.isUndefined(g_cfg.term.selected)) {
g_cfg.term.selected = '';
dom.ssh_type.html('');
if (!_.isUndefined(g_cfg.ssh)) {
if (_.isUndefined(g_cfg.ssh.selected)) {
g_cfg.ssh.selected = '';
}
if (!_.isUndefined(g_cfg.term.available) && g_cfg.term.available.length > 0) {
if (!_.isUndefined(g_cfg.ssh.available) && g_cfg.ssh.available.length > 0) {
var selected = '';
var profile = '';
var app = '';
var cmdline = '';
var html = [];
for (var i = 0; i < g_cfg.term.available.length; i++) {
var item = g_cfg.term.available[i];
for (var i = 0; i < g_cfg.ssh.available.length; i++) {
var item = g_cfg.ssh.available[i];
if (selected === '' || item.name === g_cfg.term.selected) {
if (selected === '' || item.name === g_cfg.ssh.selected) {
selected = item.name;
profile = item.profile;
app = item.app;
cmdline = item.cmdline;
}
html.push('<option id="term-' + item.name + '" value="' + item.name + '">' + item.display + '</option>');
html.push('<option value="' + item.name + '">' + item.display + '</option>');
}
dom.term_type.html(html.join(''));
dom.ssh_type.html(html.join(''));
dom.term_type.val(selected);
dom.term_profile.val(profile);
dom.ssh_type.val(selected);
dom.ssh_app.val(app);
dom.ssh_cmdline.val(cmdline);
}
}
dom.sftp_type.html('');
if (!_.isUndefined(g_cfg.sftp)) {
if (_.isUndefined(g_cfg.sftp.selected)) {
g_cfg.sftp.selected = '';
}
if (!_.isUndefined(g_cfg.sftp.available) && g_cfg.sftp.available.length > 0) {
var selected = '';
var app = '';
var cmdline = '';
var html = [];
for (var i = 0; i < g_cfg.sftp.available.length; i++) {
var item = g_cfg.sftp.available[i];
if (selected === '' || item.name === g_cfg.sftp.selected) {
selected = item.name;
app = item.app;
cmdline = item.cmdline;
}
html.push('<option value="' + item.name + '">' + item.display + '</option>');
}
dom.sftp_type.html(html.join(''));
dom.sftp_type.val(selected);
dom.sftp_app.val(app);
dom.sftp_cmdline.val(cmdline);
}
}
dom.telnet_type.html('');
if (!_.isUndefined(g_cfg.telnet)) {
if (_.isUndefined(g_cfg.telnet.selected)) {
g_cfg.telnet.selected = '';
}
if (!_.isUndefined(g_cfg.telnet.available) && g_cfg.telnet.available.length > 0) {
var selected = '';
var app = '';
var cmdline = '';
var html = [];
for (var i = 0; i < g_cfg.telnet.available.length; i++) {
var item = g_cfg.telnet.available[i];
if (selected === '' || item.name === g_cfg.telnet.selected) {
selected = item.name;
app = item.app;
cmdline = item.cmdline;
}
html.push('<option value="' + item.name + '">' + item.display + '</option>');
}
dom.telnet_type.html(html.join(''));
dom.telnet_type.val(selected);
dom.telnet_app.val(app);
dom.telnet_cmdline.val(cmdline);
}
}
dom.rdp_type.html('');
if (!_.isUndefined(g_cfg.rdp)) {
if (_.isUndefined(g_cfg.rdp.selected)) {
g_cfg.rdp.selected = '';
@ -77,6 +185,7 @@ function update_dom() {
if (!_.isUndefined(g_cfg.rdp.available) && g_cfg.rdp.available.length > 0) {
var selected = '';
var app = '';
var cmdline = '';
var html = [];
for (var i = 0; i < g_cfg.rdp.available.length; i++) {
@ -85,60 +194,55 @@ function update_dom() {
if (selected === '' || item.name === g_cfg.rdp.selected) {
selected = item.name;
app = item.app;
cmdline = item.cmdline;
}
html.push('<option id="rdp-' + item.name + '" value="' + item.name + '">' + item.display + '</option>');
html.push('<option value="' + item.name + '">' + item.display + '</option>');
}
dom.rdp_type.html(html.join(''));
dom.rdp_type.val(selected);
dom.rdp_app.val(app);
dom.rdp_cmdline.val(cmdline);
}
}
}
function on_term_change() {
g_cfg.term.selected = dom.term_type.val();
for (var i = 0; i < g_cfg.term.available.length; i++) {
var item = g_cfg.term.available[i];
if (item.name === g_cfg.term.selected) {
dom.term_profile.val(item.profile);
return;
}
}
notify_error('所选的终端配置项并不存在!');
}
function on_rdp_change() {
g_cfg.rdp.selected = dom.rdp_type.val();
for (var i = 0; i < g_cfg.rdp.available.length; i++) {
var item = g_cfg.rdp.available[i];
if (item.name === g_cfg.rdp.selected) {
dom.rdp_app.val(item.app);
return;
}
}
notify_error('所选的RDP配置项并不存在');
}
function on_save() {
if (g_cfg === null)
return;
for (var i = 0; i < g_cfg.term.available.length; i++) {
var item = g_cfg.term.available[i];
if (item.name === g_cfg.term.selected) {
item.profile = dom.term_profile.val();
var i = 0;
for (i = 0; i < g_cfg.ssh.available.length; i++) {
var item = g_cfg.ssh.available[i];
if (item.name === g_cfg.ssh.selected) {
item.app = dom.ssh_app.val();
item.cmdline = dom.ssh_cmdline.val();
break;
}
}
for (var i = 0; i < g_cfg.rdp.available.length; i++) {
for (i = 0; i < g_cfg.sftp.available.length; i++) {
var item = g_cfg.sftp.available[i];
if (item.name === g_cfg.sftp.selected) {
item.app = dom.sftp_app.val();
item.cmdline = dom.sftp_cmdline.val();
break;
}
}
for (i = 0; i < g_cfg.telnet.available.length; i++) {
var item = g_cfg.telnet.available[i];
if (item.name === g_cfg.telnet.selected) {
item.app = dom.telnet_app.val();
item.cmdline = dom.telnet_cmdline.val();
break;
}
}
for (i = 0; i < g_cfg.rdp.available.length; i++) {
var item = g_cfg.rdp.available[i];
if (item.name === g_cfg.rdp.selected) {
item.app = dom.rdp_app.val();
item.cmdline = dom.rdp_cmdline.val();
break;
}
}
@ -165,6 +269,30 @@ function on_save() {
});
}
var select_local_file = function (callback) {
var data = {
action: 1
};
var args_ = encodeURIComponent(JSON.stringify(data));
$.ajax({
type: 'GET',
timeout: -1,
url: g_url_base + '/api/file_action/' + args_,
jsonp: 'callback',
dataType: 'json',
success: function (ret) {
if(ret.code === 0)
callback(0, ret.path);
},
error: function (jqXhr, _error, _e) {
console.log('state:', jqXhr.state());
callback(-1, "");
}
});
}
function notify_error(message_, title_) {
var _title = title_ || '';
$.gritter.add({
@ -188,18 +316,104 @@ function notify_success(message_, title_) {
});
};
$(document).ready(function () {
get_version();
get_config();
dom.term_type.change(function () {
on_term_change();
dom.ssh_type.change(function () {
g_cfg.ssh.selected = dom.ssh_type.val();
for (var i = 0; i < g_cfg.ssh.available.length; i++) {
var item = g_cfg.ssh.available[i];
if (item.name === g_cfg.ssh.selected) {
dom.ssh_app.val(item.app);
dom.ssh_cmdline.val(item.cmdline);
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.ssh_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.ssh_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.sftp_type.change(function () {
g_cfg.sftp.selected = dom.sftp_type.val();
for (var i = 0; i < g_cfg.sftp.available.length; i++) {
var item = g_cfg.sftp.available[i];
if (item.name === g_cfg.sftp.selected) {
dom.sftp_app.val(item.app);
dom.sftp_cmdline.val(item.cmdline);
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.sftp_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.sftp_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.telnet_type.change(function () {
g_cfg.telnet.selected = dom.telnet_type.val();
for (var i = 0; i < g_cfg.telnet.available.length; i++) {
var item = g_cfg.telnet.available[i];
if (item.name === g_cfg.telnet.selected) {
dom.telnet_app.val(item.app);
dom.telnet_cmdline.val(item.cmdline);
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.telnet_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.telnet_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.rdp_type.change(function () {
on_rdp_change();
g_cfg.rdp.selected = dom.rdp_type.val();
for (var i = 0; i < g_cfg.rdp.available.length; i++) {
var item = g_cfg.rdp.available[i];
if (item.name === g_cfg.rdp.selected) {
dom.rdp_app.val(item.app);
dom.rdp_cmdline.val(item.cmdline);
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.rdp_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.rdp_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.btn_save.click(function () {
on_save();
});
});
});

View File

@ -30,7 +30,7 @@ html, body {
//text-align: center;
line-height: @header-height;
//border-bottom: 1px solid darken(@toolbar-bg, 20%);
font-size: 80%;
//font-size: 80%;
background-color: #3b3b3b;
color: #fff;
@ -58,7 +58,7 @@ html, body {
line-height: @footer-height;
background-color: @toolbar-bg;
border-top: 1px solid darken(@toolbar-bg, 20%);
font-size: 80%;
//font-size: 80%;
z-index: 999;
}
@ -74,24 +74,18 @@ html, body {
margin-bottom: 5px;
}
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11 {
padding-left: 3px;
padding-right: 3px;
}
.arg-detail {
font-size: 11px;
//font-size: 13px;
ol, ul {
margin-bottom: 0;
}
}
.desc {
display:inline-block;
margin-top:5px;
color:rgb(107, 107, 107);
}
.arg-detail-common {
//border:1px solid #f33;
background-color: #dbffbe;
@ -111,7 +105,7 @@ html, body {
font-weight: bold;
font-family: @font-family-mono;
display: inline-block;
width: 128px;
width: 164px;
//margin-right:20px;
}

View File

@ -38,28 +38,29 @@ NSDictionary *plistDict;
plistDict = [[NSBundle mainBundle] infoDictionary];
//Get the application name.
id applicationName = [plistDict objectForKey:@"CFBundleName"];
// id applicationName = [plistDict objectForKey:@"CFBundleName"];
//Get the build version.
id applicationVersion = [plistDict objectForKey:@"CFBundleVersion"];
//Get the copyright.
id applicationCopyright = [plistDict objectForKey:@"NSHumanReadableCopyright"];
// id applicationCopyright = [plistDict objectForKey:@"NSHumanReadableCopyright"];
//Build the string for the windows title.
NSString *aboutTitle = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"About ",nil), applicationName];
[aboutWindow.window setTitle:aboutTitle];
// NSString *aboutTitle = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"About ",nil), applicationName];
NSString *strTitle = [NSString stringWithFormat:@"%@%@",
NSLocalizedString(@"about ",nil),
NSLocalizedString(@"app_name",nil)];
[aboutWindow.window setTitle:strTitle];
//Build the string for the application name. appName - tagline
NSString *progName = [NSString stringWithFormat:@"%@", NSLocalizedString(@"Teleport Assist",nil)];
[appName setStringValue:progName];
NSString *strProgName = [NSString stringWithFormat:@"%@", NSLocalizedString(@"app_full_name", nil)];
[appName setStringValue:strProgName];
//Build the string for the version. Version: $build
NSString *progVersion = [NSString stringWithFormat:@"%@", applicationVersion];
[appVersion setStringValue:progVersion];
//Make the copyright font smaller.
// [appCopyright setFont:[NSFont systemFontOfSize:10]];
[appCopyright setStringValue:applicationCopyright];
NSString *strVersion = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"version", nil), applicationVersion];
[appVersion setStringValue:strVersion];
NSString *strCopyright = [NSString stringWithFormat:@"%@", NSLocalizedString(@"copyright", nil)];
[appCopyright setStringValue:strCopyright];
}
- (IBAction)btnHomepage:(id)sender {

View File

@ -44,7 +44,7 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char*
// if the config file does not exist, create a default one
if ( ![[NSFileManager defaultManager] fileExistsAtPath:cfgFile] ) {
NSString *cfgFileInResource = [[NSBundle mainBundle] pathForResource:@"tp-assist.default" ofType:@"json"];
NSString *cfgFileInResource = [[NSBundle mainBundle] pathForResource:@"tp-assist.macos" ofType:@"json"];
[[NSFileManager defaultManager] copyItemAtPath:cfgFileInResource toPath:cfgFile error:nil];
}
@ -67,9 +67,6 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char*
// Needed to trigger the menuWillOpen event
[menu setDelegate:self];
//http_rpc_start((__bridge void*)self);
NSString *resPath = [[NSBundle mainBundle] resourcePath];
std::string cpp_res_path = [resPath cStringUsingEncoding:NSUTF8StringEncoding];
@ -87,11 +84,20 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char*
else
msg = @"发生未知错误!";
NSAlert *alert = [NSAlert alertWithMessageText:@"无法启动Teleport助手"
defaultButton:@"确定"
alternateButton:Nil
otherButton:Nil
informativeTextWithFormat:msg];
NSAlert *alert = [[NSAlert alloc] init];
alert.icon = [NSImage imageNamed:@"tpassist"];
[alert addButtonWithTitle:@"确定"];
[alert setMessageText:@"无法启动Teleport助手"];
[alert setInformativeText:msg];
[alert runModal];
// NSAlert *alert = [NSAlert alertWithMessageText:@"无法启动Teleport助手"
// defaultButton:@"确定"
// alternateButton:Nil
// otherButton:Nil
// informativeTextWithFormat:@"%@", msg];
[alert runModal];
http_rpc_stop();
@ -134,7 +140,8 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char*
//Create the container event
//We need these constants from the Carbon OpenScripting framework, but we don't actually need Carbon.framework...
// We need these constants from the Carbon OpenScripting framework,
// but we don't actually need Carbon.framework...
#define kASAppleScriptSuite 'ascr'
#define kASSubroutineEvent 'psbr'
#define keyASSubroutineName 'snam'

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -16,11 +16,11 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="About Teleport Assist" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<window title="About Teleport Assist" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="750" y="574" width="315" height="204"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<rect key="screenRect" x="0.0" y="0.0" width="2048" height="1129"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="315" height="204"/>
<autoresizingMask key="autoresizingMask"/>
@ -53,7 +53,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Homepage" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="uUM-88-32s">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system" size="11"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<action selector="btnHomepage:" target="-2" id="ZGb-bg-pCR"/>
@ -73,7 +73,7 @@
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="51" y="233"/>
<point key="canvasLocation" x="50.5" y="233"/>
</window>
</objects>
<resources>

View File

@ -2,3 +2,13 @@
Localizable.strings
TPAssist
*/
"app_name" = "Teleport助手";
//=============================================
// for About Window
//=============================================
"version" = "Version: ";
"app_full_name" = "Teleport Assist for macOS";
"copyright" = "Copyright © 2017~2018 TP4A. All rights reserved.";
"visit_tp4a_website" = "Visit Teleport Website"

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<development version="10000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">

Binary file not shown.

View File

@ -19,6 +19,20 @@ bool TsCfg::init(void) {
if(!_load(file_content))
return false;
if(!m_root.isObject()) {
EXLOGE("invalid config file, not in json format?\n");
return false;
}
if(m_root["file_version"].isNull()) {
EXLOGE("invalid config file, maybe need create new one?\n");
return false;
}
if(!m_root["file_version"].isInt()) {
}
return true;
}
@ -38,6 +52,78 @@ bool TsCfg::save(const ex_astr& new_value)
return true;
}
bool TsCfg::_parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CONFIG& cfg) {
const Json::Value& jApp = m_root[str_app.c_str()];
if(!jApp.isObject())
return false;
if (!jApp["selected"].isString()) {
EXLOGE("invalid config, error 2.\n");
return false;
}
ex_astr _selected = jApp["selected"].asCString();;
if (!jApp["available"].isArray() || jApp["available"].size() == 0) {
EXLOGE("invalid config, error 3.\n");
return false;
}
const Json::Value& jAppList = jApp["available"];
int i = 0;
for (i = 0; i < jAppList.size(); ++i) {
if (
!jAppList[i]["name"].isString()
|| !jAppList[i]["app"].isString()
|| !jAppList[i]["cmdline"].isString()
|| !jAppList[i]["desc"].isArray()
) {
EXLOGE("invalid config, error 4.\n");
return false;
}
if(jAppList[i]["name"].asString().empty()) {
EXLOGE("invalid config, need name.\n");
return false;
}
if (jAppList[i]["display"].isNull() || jAppList[i]["display"].asString().empty()) {
cfg.display = jAppList[i]["name"].asCString();
} else
cfg.display = jAppList[i]["display"].asCString();
if (jAppList[i]["name"].asCString() != _selected)
continue;
cfg.name = jAppList[i]["name"].asCString();
cfg.display = jAppList[i]["display"].asCString();
cfg.application = jAppList[i]["app"].asCString();
cfg.cmdline = jAppList[i]["cmdline"].asCString();
if(jAppList[i]["desc"].size() > 0) {
// cfg.description = jApp["available"][i]["app"].asCString();
const Json::Value& jAppDescList = jAppList[i]["desc"];
int j = 0;
for(j = 0; j < jAppDescList.size(); ++j) {
if(!jAppDescList[i].isString())
return false;
cfg.description.push_back(jAppDescList[i].asCString());
}
}
break;
}
if (cfg.application.empty() || cfg.cmdline.empty()) {
EXLOGE("invalid config, error 6.\n");
return false;
}
return true;
}
bool TsCfg::_load(const ex_astr& str_json) {
Json::Reader jreader;
@ -46,14 +132,13 @@ bool TsCfg::_load(const ex_astr& str_json) {
return false;
}
ex_astr sel_name;
int i = 0;
ex_astr tmp;
//===================================
// check ssh config
//===================================
if(!_parse_app(m_root, "ssh", ssh))
return false;
#if 0
if (!m_root["ssh"].isObject()) {
EXLOGE("invalid config, error 1.\n");
return false;
@ -265,6 +350,7 @@ bool TsCfg::_load(const ex_astr& str_json) {
EXLOGE("invalid config, error 6.\n");
return false;
}
#endif
#if 0
// ------------ term ---------------------

View File

@ -6,6 +6,14 @@
#include <json/json.h>
typedef struct APP_CONFIG {
ex_astr name;
ex_astr display;
ex_astr application;
ex_astr cmdline;
ex_astrs description;
}APP_CONFIG;
class TsCfg
{
public:
@ -17,29 +25,14 @@ public:
Json::Value& get_root() {return m_root;}
// ex_astr term_name;
// ex_astr term_display;
// ex_astr term_app;
// ex_astr term_profile;
ex_astr ssh_app;
ex_astr ssh_cmdline;
ex_astr scp_app;
ex_astr scp_cmdline;
ex_astr telnet_app;
ex_astr telnet_cmdline;
ex_astr rdp_name;
ex_astr rdp_app;
ex_astr rdp_cmdline;
APP_CONFIG ssh;
APP_CONFIG sftp;
APP_CONFIG telnet;
APP_CONFIG rdp;
// ex_astr rdp_name;
// ex_astr rdp_display;
// ex_astr rdp_app;
//ex_astr rdp_cmdline;
protected:
bool _load(const ex_astr& str_json);
bool _parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CONFIG& cfg);
protected:
Json::Value m_root;

View File

@ -1,4 +1,3 @@
//#include "stdafx.h"
#include "ts_env.h"
#include <time.h>
@ -24,12 +23,12 @@ bool TsEnv::init(const char* cfg_file, const char* res_path)
ex_astr2wstr(cfg_file, m_cfg_file);
ex_astr2wstr(res_path, m_res_path);
//#ifdef EX_DEBUG
// m_site_path = L"/Users/apex/work/tp4a/teleport/client/tp_assist_macos/site";
//#else
#ifdef EX_DEBUG
m_site_path = L"/Users/apex/work/tp4a/teleport/client/tp_assist_macos/site";
#else
m_site_path = m_res_path;
ex_path_join(m_site_path, false, L"site", NULL);
//#endif
#endif
return true;
}

View File

@ -1,9 +1,3 @@
//#include "stdafx.h"
//#pragma warning(disable:4091)
//#include <commdlg.h>
//#include <ShlObj.h>
#include <unistd.h>
#include <teleport_const.h>
@ -15,7 +9,6 @@
#include "../AppDelegate-C-Interface.h"
#include "ts_http_rpc.h"
//#include "dlg_main.h"
#include "ts_ver.h"
#include "ts_env.h"
#include "ts_cfg.h"
@ -140,7 +133,7 @@ bool TsHttpRpc::init(const char* ip, int port)
void TsHttpRpc::_thread_loop(void)
{
while (!m_stop_flag)
while (!m_need_stop)
{
mg_mgr_poll(&m_mg_mgr, 500);
}
@ -148,10 +141,10 @@ void TsHttpRpc::_thread_loop(void)
EXLOGV("[core] rpc main loop end.\n");
}
void TsHttpRpc::_set_stop_flag(void)
{
m_stop_flag = true;
}
//void TsHttpRpc::_set_stop_flag(void)
//{
// m_stop_flag = true;
//}
void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_data)
{
@ -478,7 +471,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
// RDP
//==============================================
if(g_cfg.rdp_app.length() == 0) {
if(g_cfg.rdp.application.length() == 0) {
_create_json_ret(buf, TPE_NOT_EXISTS);
return;
}
@ -546,7 +539,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
//w_exe_path = _T("/usr/local/Cellar/freerdp/1.0.2_1/bin/xfreerdp -u {user_name} {size} {console} ");
//w_exe_path = _T("xfreerdp -u {user_name} {size} {console} ");
//s_exec = "/usr/local/Cellar/freerdp/1.0.2_1/bin/xfreerdp";
s_exec = g_cfg.rdp_app;
s_exec = g_cfg.rdp.application;
s_argv.push_back(s_exec.c_str());
{
@ -594,18 +587,21 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
if (pro_sub == TP_PROTOCOL_TYPE_SSH_SHELL)
{
char szCmd[1024] = {0};
ex_strformat(szCmd, 1023, "ssh %s@%s -p %d", sid.c_str(), teleport_ip.c_str(), teleport_port);
char szTitle[128] = {0};
ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str());
int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.term_name.c_str(), g_cfg.term_profile.c_str(), szTitle);
if(ret == 0)
_create_json_ret(buf, TPE_OK);
else
_create_json_ret(buf, TPE_FAILED);
return;
if(g_cfg.ssh.name == "terminal" || g_cfg.ssh.name == "iterm2") {
char szCmd[1024] = {0};
ex_strformat(szCmd, 1023, "ssh %s@%s -p %d", sid.c_str(), teleport_ip.c_str(), teleport_port);
char szTitle[128] = {0};
ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str());
int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.ssh.name.c_str(), g_cfg.ssh.cmdline.c_str(), szTitle);
if(ret == 0)
_create_json_ret(buf, TPE_OK);
else
_create_json_ret(buf, TPE_FAILED);
return;
}
}
else
{

View File

@ -14,29 +14,38 @@
/*
//=================================================================
使
127.0.0.1:50022http
# HTTP-RPC-INTERFACE:
listen on http://localhost:50022 and https://localhost:50023.
----------------
GET method:
http://127.0.0.1:50022/method/json_param
here `json_param` is string in json format and encoded by url_encode().
GET
http://127.0.0.1:50022/method/json_param
json_param使url_encodejson
----------------
POST method
http://127.0.0.1:50022/method
POST
http://127.0.0.1:50022/method
postjson_param
here the data field of POST should be json_param.
## URI detail:
- method the method to request to execute.
- json_param param of the method and it is optional.
URI
method
json_param
## RESULT
json
{"code":0,"data":varb}
code0datadata
A string in json format should returned with following format:
{"code":0,"data":varb}
`code` field always exists and 0 means success.
`data` field is optional.
*/
int http_rpc_start(void* app);
@ -67,7 +76,8 @@ public:
protected:
void _thread_loop(void);
void _set_stop_flag(void);
// void _set_stop_flag(void);
// void _on_stop();
private:
int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args);

View File

@ -1,6 +1,6 @@
#ifndef __TS_ASSIST_VER_H__
#define __TS_ASSIST_VER_H__
#define TP_ASSIST_VER L"3.1.0"
#define TP_ASSIST_VER L"3.2.0"
#endif // __TS_ASSIST_VER_H__

View File

@ -1,15 +1,2 @@
/* Class = "NSTextFieldCell"; title = "Version"; ObjectID = "6fl-Xm-UPS"; */
"6fl-Xm-UPS.title" = "Version";
/* Class = "NSTextFieldCell"; title = "Copyright"; ObjectID = "Cmu-CQ-3V9"; */
"Cmu-CQ-3V9.title" = "Copyright";
/* Class = "NSWindow"; title = "Window"; ObjectID = "F0z-JX-Cv5"; */
"F0z-JX-Cv5.title" = "Window";
/* Class = "NSTextFieldCell"; title = "Program Name and Tag Line"; ObjectID = "tb3-eK-HAT"; */
"tb3-eK-HAT.title" = "Teleport Assistor for MacOS";
/* Class = "NSButtonCell"; title = "Homepage"; ObjectID = "uUM-88-32s"; */
"uUM-88-32s.title" = "Visit TELEPORT Website";
"uUM-88-32s.title" = "Visit Teleport Website";

View File

@ -15,7 +15,7 @@
"136.title" = "Quit TPAssist";
/* Class = "NSMenuItem"; title = "About"; ObjectID = "638"; */
"638.title" = "About";
"638.title" = "About Teleport Assist";
/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "644"; */
"644.title" = "Quit";
@ -23,11 +23,4 @@
/* Class = "NSMenuItem"; title = "Settings"; ObjectID = "646"; */
"646.title" = "Settings";
/* Class = "NSMenu"; title = "Settings"; ObjectID = "647"; */
"647.title" = "Settings";
/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "648"; */
"648.title" = "Edit";
/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "649"; */
"649.title" = "Quit";
"pkv-BD-W9b.title" = "Visit Teleport Website";

View File

@ -1,30 +0,0 @@
{
"term": {
"selected": "Terminal",
"available": [
{
"name":"Terminal",
"display": "终端(系统自带)",
"app": "Terminal.app",
"profile": "Basic"
},
{
"name": "iTerm2",
"display": "iTerm2",
"app": "iTerm2.app",
"profile": "Default"
}
]
},
"rdp": {
"selected": "FreeRDP",
"available": [
{
"name": "FreeRDP",
"display": "FreeRDP",
"app": ""
}
]
}
}

View File

@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.1.0</string>
<string>3.2.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -1,15 +1,2 @@
/* Class = "NSTextFieldCell"; title = "Version"; ObjectID = "6fl-Xm-UPS"; */
"6fl-Xm-UPS.title" = "Version";
/* Class = "NSTextFieldCell"; title = "Copyright"; ObjectID = "Cmu-CQ-3V9"; */
"Cmu-CQ-3V9.title" = "Copyright";
/* Class = "NSWindow"; title = "Window"; ObjectID = "F0z-JX-Cv5"; */
"F0z-JX-Cv5.title" = "Window";
/* Class = "NSTextFieldCell"; title = "Program Name and Tag Line"; ObjectID = "tb3-eK-HAT"; */
"tb3-eK-HAT.title" = "Teleport助手 for MacOS";
/* Class = "NSButtonCell"; title = "官方网站"; ObjectID = "uUM-88-32s"; */
"uUM-88-32s.title" = "访问TELEPORT官方网站";
"uUM-88-32s.title" = "访问 Teleport 网站";

View File

@ -7,9 +7,13 @@
/* NSLocalizedString(@"",nil)*/
"About " = "关于 ";
//"Version: " = "版本:";
"Teleport Assist" = "Teleport 助手 - macOS";
"app_name" = "Teleport助手";
"Quit" = "退出";
//"Continue" = "继续";
//=============================================
// for About Window
//=============================================
"about " = "关于 ";
"version" = "版本:";
"app_full_name" = "Teleport助手 - macOS";
"copyright" = "© 2017~2018 TP4A保留所有权利。";
"visit_tp4a_website" = "访问 Teleport 网站";

View File

@ -15,7 +15,7 @@
"136.title" = "退出 TPAssist";
/* Class = "NSMenuItem"; title = "关于"; ObjectID = "638"; */
"638.title" = "关于";
"638.title" = "关于Teleport助手";
/* Class = "NSMenuItem"; title = "退出"; ObjectID = "644"; */
"644.title" = "退出";
@ -23,11 +23,4 @@
/* Class = "NSMenuItem"; title = "设置"; ObjectID = "646"; */
"646.title" = "设置";
/* Class = "NSMenu"; title = "设置"; ObjectID = "647"; */
"647.title" = "设置";
/* Class = "NSMenuItem"; title = "编辑"; ObjectID = "648"; */
"648.title" = "编辑";
/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "649"; */
"649.title" = "Quit";
"pkv-BD-W9b.title" = "访问Teleport网站";

View File

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 51;
objects = {
/* Begin PBXBuildFile section */
@ -11,12 +11,18 @@
0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */; };
7A0C94AA1F68BD2900E04C3E /* AboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6FC541A51D45CF7F00A896E3 /* AboutWindowController.xib */; };
7A18188F1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A18188E1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp */; };
7A1818911F7FBBC200F3C882 /* tp-assist.default.json in Resources */ = {isa = PBXBuildFile; fileRef = 7A1818901F7FBBC200F3C882 /* tp-assist.default.json */; };
7A1F87AD215D59BD00B69F88 /* Terminal.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87AB215D59BD00B69F88 /* Terminal.scpt */; };
7A1F87AE215D59BD00B69F88 /* iTerm2.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87AC215D59BD00B69F88 /* iTerm2.scpt */; };
7A1F87B1215D5A1600B69F88 /* StatusIconAlt@2X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */; };
7A1F87B2215D5A1600B69F88 /* StatusIcon@2X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */; };
7A27E4A91F6A8EEC004FDE5D /* ts_env.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */; };
7A7C6C9121973C24006869D9 /* StatusIconAlt@3X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */; };
7A7C6C9221973C24006869D9 /* StatusIcon@3X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */; };
7A7C6C9621973C69006869D9 /* tpassist.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9521973C69006869D9 /* tpassist.png */; };
7A7C6C9C21974094006869D9 /* cacert.cer in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9921974094006869D9 /* cacert.cer */; };
7A7C6C9D21974094006869D9 /* localhost.key in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9A21974094006869D9 /* localhost.key */; };
7A7C6C9E21974094006869D9 /* localhost.pem in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9B21974094006869D9 /* localhost.pem */; };
7A7C6CA02197410B006869D9 /* tp-assist.macos.json in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */; };
7A7C6CAA21977F07006869D9 /* iterm2.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6CA821977F07006869D9 /* iterm2.scpt */; };
7A7C6CAB21977F07006869D9 /* terminal.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6CA921977F07006869D9 /* terminal.scpt */; };
7AA2CD381F6A92620074C92B /* ts_http_rpc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD371F6A92620074C92B /* ts_http_rpc.cpp */; };
7AA2CD3B1F6A955A0074C92B /* ts_cfg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD391F6A955A0074C92B /* ts_cfg.cpp */; };
7AA2CD441F6AB9750074C92B /* ex_ini.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD3D1F6AB9750074C92B /* ex_ini.cpp */; };
@ -45,7 +51,6 @@
0ADB3B08178EF8DB004E9BB9 /* StatusIconAlt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = StatusIconAlt.png; sourceTree = "<group>"; };
0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = StatusIcon.png; sourceTree = "<group>"; };
7A18188E1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "AppDelegate-C-Interface.cpp"; sourceTree = "<group>"; };
7A1818901F7FBBC200F3C882 /* tp-assist.default.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "tp-assist.default.json"; sourceTree = "<group>"; };
7A1818951F8242E900F3C882 /* apple-scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "apple-scripts"; sourceTree = "<group>"; };
7A1F8797215D565600B69F88 /* ex_util.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_util.h; path = ../../../../common/libex/include/ex/ex_util.h; sourceTree = "<group>"; };
7A1F8798215D565600B69F88 /* ex_ini.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_ini.h; path = ../../../../common/libex/include/ex/ex_ini.h; sourceTree = "<group>"; };
@ -55,7 +60,7 @@
7A1F879D215D565600B69F88 /* ex_types.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_types.h; path = ../../../../common/libex/include/ex/ex_types.h; sourceTree = "<group>"; };
7A1F879E215D565700B69F88 /* ex_str.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_str.h; path = ../../../../common/libex/include/ex/ex_str.h; sourceTree = "<group>"; };
7A1F879F215D565700B69F88 /* ex_path.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_path.h; path = ../../../../common/libex/include/ex/ex_path.h; sourceTree = "<group>"; };
7A1F87A0215D565700B69F88 /* ex_thread.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_thread.h; path = ../../../../common/libex/include/ex/ex_thread.h; sourceTree = "<group>"; };
7A1F87A0215D565700B69F88 /* ex_thread.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 2147486000; name = ex_thread.h; path = ../../../../common/libex/include/ex/ex_thread.h; sourceTree = "<group>"; };
7A1F87A1215D56B500B69F88 /* writer.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = writer.h; path = ../../../../external/jsoncpp/include/json/writer.h; sourceTree = "<group>"; };
7A1F87A2215D570000B69F88 /* value.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = value.h; path = ../../../../external/jsoncpp/include/json/value.h; sourceTree = "<group>"; };
7A1F87A3215D570000B69F88 /* reader.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = reader.h; path = ../../../../external/jsoncpp/include/json/reader.h; sourceTree = "<group>"; };
@ -66,14 +71,22 @@
7A1F87A8215D574500B69F88 /* assertions.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = assertions.h; path = ../../../../external/jsoncpp/include/json/assertions.h; sourceTree = "<group>"; };
7A1F87A9215D574500B69F88 /* autolink.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = autolink.h; path = ../../../../external/jsoncpp/include/json/autolink.h; sourceTree = "<group>"; };
7A1F87AA215D574500B69F88 /* version.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = version.h; path = ../../../../external/jsoncpp/include/json/version.h; sourceTree = "<group>"; };
7A1F87AB215D59BD00B69F88 /* Terminal.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = Terminal.scpt; sourceTree = "<group>"; };
7A1F87AC215D59BD00B69F88 /* iTerm2.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = iTerm2.scpt; sourceTree = "<group>"; };
7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@2X.png"; sourceTree = "<group>"; };
7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@2X.png"; sourceTree = "<group>"; };
7A27E4A61F6A899B004FDE5D /* ts_const.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_const.h; sourceTree = "<group>"; };
7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_env.cpp; sourceTree = "<group>"; };
7A27E4A81F6A8EEC004FDE5D /* ts_env.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_env.h; sourceTree = "<group>"; };
7A40FFE21F7B2A4500F11697 /* AppDelegate-C-Interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate-C-Interface.h"; sourceTree = "<group>"; };
7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@3X.png"; sourceTree = "<group>"; };
7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@3X.png"; sourceTree = "<group>"; };
7A7C6C9521973C69006869D9 /* tpassist.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tpassist.png; sourceTree = "<group>"; };
7A7C6C9921974094006869D9 /* cacert.cer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = cacert.cer; path = ../../../cfg/cacert.cer; sourceTree = "<group>"; };
7A7C6C9A21974094006869D9 /* localhost.key */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = localhost.key; path = ../../../cfg/localhost.key; sourceTree = "<group>"; };
7A7C6C9B21974094006869D9 /* localhost.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = localhost.pem; path = ../../../cfg/localhost.pem; sourceTree = "<group>"; };
7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "tp-assist.macos.json"; path = "../../../cfg/tp-assist.macos.json"; sourceTree = "<group>"; };
7A7C6CA12197786B006869D9 /* ts_ver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ts_ver.h; sourceTree = "<group>"; };
7A7C6CA821977F07006869D9 /* iterm2.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = iterm2.scpt; sourceTree = "<group>"; };
7A7C6CA921977F07006869D9 /* terminal.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = terminal.scpt; sourceTree = "<group>"; };
7AA2CD361F6A92380074C92B /* ts_http_rpc.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 2147486000; path = ts_http_rpc.h; sourceTree = "<group>"; };
7AA2CD371F6A92620074C92B /* ts_http_rpc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_http_rpc.cpp; sourceTree = "<group>"; };
7AA2CD391F6A955A0074C92B /* ts_cfg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_cfg.cpp; sourceTree = "<group>"; };
@ -114,7 +127,7 @@
C149EC0B15D5214600B1F558 /* tp_assist-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "tp_assist-Prefix.pch"; sourceTree = "<group>"; };
C149EC0F15D5214600B1F558 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
C149EC1015D5214600B1F558 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
C159DC2715D5DE7F00F5DE24 /* teleport.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = teleport.icns; path = ../teleport.icns; sourceTree = "<group>"; };
C159DC2715D5DE7F00F5DE24 /* teleport.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = teleport.icns; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -132,6 +145,9 @@
0ADB3B10178EF8E2004E9BB9 /* Images */ = {
isa = PBXGroup;
children = (
7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */,
7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */,
7A7C6C9521973C69006869D9 /* tpassist.png */,
7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */,
7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */,
0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */,
@ -140,6 +156,17 @@
name = Images;
sourceTree = "<group>";
};
7A45423D2196E32800FEB5B4 /* cfg */ = {
isa = PBXGroup;
children = (
7A7C6C9921974094006869D9 /* cacert.cer */,
7A7C6C9A21974094006869D9 /* localhost.key */,
7A7C6C9B21974094006869D9 /* localhost.pem */,
7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */,
);
path = cfg;
sourceTree = "<group>";
};
7AA2CD3C1F6AB9560074C92B /* libex */ = {
isa = PBXGroup;
children = (
@ -206,6 +233,7 @@
7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */,
7A27E4A81F6A8EEC004FDE5D /* ts_env.h */,
7A27E4A61F6A899B004FDE5D /* ts_const.h */,
7A7C6CA12197786B006869D9 /* ts_ver.h */,
);
path = csrc;
sourceTree = "<group>";
@ -213,8 +241,8 @@
A12D9BE61BCF2C72004F52A6 /* apple-scpt */ = {
isa = PBXGroup;
children = (
7A1F87AC215D59BD00B69F88 /* iTerm2.scpt */,
7A1F87AB215D59BD00B69F88 /* Terminal.scpt */,
7A7C6CA821977F07006869D9 /* iterm2.scpt */,
7A7C6CA921977F07006869D9 /* terminal.scpt */,
);
path = "apple-scpt";
sourceTree = "<group>";
@ -224,9 +252,9 @@
children = (
7A1818951F8242E900F3C882 /* apple-scripts */,
7AA2CD581F6AC0DA0074C92B /* site */,
C149EC0315D5214600B1F558 /* src */,
C149EBFC15D5214600B1F558 /* Frameworks */,
C149EBFA15D5214600B1F558 /* Products */,
C149EC0315D5214600B1F558 /* src */,
);
sourceTree = "<group>";
};
@ -260,10 +288,10 @@
C149EC0315D5214600B1F558 /* src */ = {
isa = PBXGroup;
children = (
7A1818901F7FBBC200F3C882 /* tp-assist.default.json */,
7A45423D2196E32800FEB5B4 /* cfg */,
7AD3E8741F6A7CC600D2EB48 /* csrc */,
A12D9BE61BCF2C72004F52A6 /* apple-scpt */,
C159DC2715D5DE7F00F5DE24 /* teleport.icns */,
C149EC0915D5214600B1F558 /* main.m */,
C149EC0F15D5214600B1F558 /* AppDelegate.h */,
C149EC1015D5214600B1F558 /* AppDelegate.mm */,
C149EC1215D5214600B1F558 /* MainMenu.xib */,
@ -281,9 +309,9 @@
C149EC0415D5214600B1F558 /* Supporting Files */ = {
isa = PBXGroup;
children = (
C159DC2715D5DE7F00F5DE24 /* teleport.icns */,
C149EC0515D5214600B1F558 /* tp_assist-Info.plist */,
C149EC0615D5214600B1F558 /* InfoPlist.strings */,
C149EC0915D5214600B1F558 /* main.m */,
C149EC0B15D5214600B1F558 /* tp_assist-Prefix.pch */,
A1B7B9DF1DB53ED200809327 /* Localizable.strings */,
);
@ -317,10 +345,10 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = eomsoft;
ORGANIZATIONNAME = TP4A;
};
buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "tp_assist" */;
compatibilityVersion = "Xcode 3.2";
compatibilityVersion = "Xcode 10.0";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
@ -345,17 +373,23 @@
files = (
7AA2CD591F6AC0DA0074C92B /* site in Resources */,
A1B7B9DD1DB53ED200809327 /* Localizable.strings in Resources */,
0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */,
7A1F87B1215D5A1600B69F88 /* StatusIconAlt@2X.png in Resources */,
7A1F87AE215D59BD00B69F88 /* iTerm2.scpt in Resources */,
0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */,
C149EC0815D5214600B1F558 /* InfoPlist.strings in Resources */,
7A1F87AD215D59BD00B69F88 /* Terminal.scpt in Resources */,
7A7C6CA02197410B006869D9 /* tp-assist.macos.json in Resources */,
7A7C6C9E21974094006869D9 /* localhost.pem in Resources */,
7A7C6C9621973C69006869D9 /* tpassist.png in Resources */,
7A7C6C9C21974094006869D9 /* cacert.cer in Resources */,
C149EC1415D5214600B1F558 /* MainMenu.xib in Resources */,
7A7C6C9D21974094006869D9 /* localhost.key in Resources */,
C159DC2815D5DE8000F5DE24 /* teleport.icns in Resources */,
7A0C94AA1F68BD2900E04C3E /* AboutWindowController.xib in Resources */,
7A1818911F7FBBC200F3C882 /* tp-assist.default.json in Resources */,
0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */,
7A1F87B2215D5A1600B69F88 /* StatusIcon@2X.png in Resources */,
7A7C6C9221973C24006869D9 /* StatusIcon@3X.png in Resources */,
0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */,
7A1F87B1215D5A1600B69F88 /* StatusIconAlt@2X.png in Resources */,
7A7C6C9121973C24006869D9 /* StatusIconAlt@3X.png in Resources */,
7A7C6CAA21977F07006869D9 /* iterm2.scpt in Resources */,
7A7C6CAB21977F07006869D9 /* terminal.scpt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -481,9 +515,10 @@
../../external/mongoose,
../../external/jsoncpp/include,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VALID_ARCHS = x86_64;
};
name = Debug;
};
@ -530,8 +565,9 @@
../../external/mongoose,
../../external/jsoncpp/include,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.10;
SDKROOT = macosx;
VALID_ARCHS = x86_64;
};
name = Release;
};
@ -543,9 +579,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
INFOPLIST_FILE = "src/tp_assist-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = x86_64;
WRAPPER_EXTENSION = app;
};
name = Debug;
@ -558,9 +595,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
INFOPLIST_FILE = "src/tp_assist-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = x86_64;
WRAPPER_EXTENSION = app;
};
name = Release;

View File

@ -92,7 +92,7 @@ public:
int Count(void) const
{
return m_secs.size();
return (int)(m_secs.size());
}
void Save(int codepage = EX_CODEPAGE_UTF8);
#ifdef EX_DEBUG

View File

@ -174,7 +174,7 @@ EX_BOOL ex_copy_file(const wchar_t* from_file, const wchar_t* to_file) {
if (S_ISLNK(src_stat.st_mode)) {
char lnk[1024] = {0};
int lnk_size;
ssize_t lnk_size;
if ((lnk_size = readlink(source.c_str(), lnk, 1023)) == -1)
return EX_FALSE;
lnk[lnk_size] = '\0';
@ -183,7 +183,7 @@ EX_BOOL ex_copy_file(const wchar_t* from_file, const wchar_t* to_file) {
}
else if (S_ISREG(src_stat.st_mode)) {
int src = -1, dst = -1;
int rsize = 0;
ssize_t rsize = 0;
char buf[1024] = {0};
if ((src = open(source.c_str(), O_RDONLY)) == -1) {
close(dst);

View File

@ -308,166 +308,170 @@ void ex_dlclose(EX_DYLIB_HANDLE dylib) {
// return _inet_ntop4((const unsigned char *) &(src->sin_addr), dst, size);
// }
//
static const char * _inet_ntop_v4(const void *src, char *dst, size_t size)
{
const char digits[] = "0123456789";
int i;
struct in_addr *addr = (struct in_addr *)src;
u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < EX_IPV4_NAME_LEN) {
//errno = ENOSPC;
return NULL;
}
for (i = 0; i < 4; ++i) {
int n = (a >> (24 - i * 8)) & 0xFF;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
*dst++ = digits[n / 100];
n %= 100;
non_zerop = 1;
}
if (non_zerop || n / 10 > 0) {
*dst++ = digits[n / 10];
n %= 10;
non_zerop = 1;
}
*dst++ = digits[n];
if (i != 3)
*dst++ = '.';
}
*dst++ = '\0';
return orig_dst;
static const char * _inet_ntop_v4(const void *src, char *dst, size_t size)
{
const char digits[] = "0123456789";
int i;
struct in_addr *addr = (struct in_addr *)src;
u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < EX_IPV4_NAME_LEN) {
//errno = ENOSPC;
return NULL;
}
for (i = 0; i < 4; ++i) {
int n = (a >> (24 - i * 8)) & 0xFF;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
*dst++ = digits[n / 100];
n %= 100;
non_zerop = 1;
}
if (non_zerop || n / 10 > 0) {
*dst++ = digits[n / 10];
n %= 10;
non_zerop = 1;
}
*dst++ = digits[n];
if (i != 3)
*dst++ = '.';
}
*dst++ = '\0';
return orig_dst;
}
#define IN6ADDRSZ 16
#define IN6ADDRSZ 16
#define INT16SZ 2
static const char * _inet_ntop_v6(const ex_u8 *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[EX_IPV6_NAME_LEN];
char *tp;
struct {
long base;
long len;
} best, cur;
u_long words[IN6ADDRSZ / INT16SZ];
int i;
/* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, 0, sizeof(words));
for (i = 0; i < IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
if (words[i] == 0)
{
if (cur.base == -1)
cur.base = i, cur.len = 1;
else cur.len++;
}
else if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
best = cur;
if (best.base != -1 && best.len < 2)
best.base = -1;
/* Format the result.
*/
tp = tmp;
size_t tmp_size = 0;
size_t offset = 0;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
/* Are we inside the best run of 0x00's?
*/
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base) {
*tp++ = ':';
offset += 1;
}
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if (i != 0) {
*tp++ = ':';
offset += 1;
}
/* Is this address an encapsulated IPv4?
*/
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!_inet_ntop_v4(src + 12, tp, sizeof(tmp) - (tp - tmp)))
{
//errno = ENOSPC;
return (NULL);
}
tmp_size = strlen(tp);
tp += tmp_size;
offset += tmp_size;
break;
}
//tp += ex_strformat(tp, "%lX", words[i]);
tmp_size = ex_strformat(tp, EX_IPV6_NAME_LEN-offset, "%lX", words[i]);
tp += tmp_size;
offset += tmp_size;
}
/* Was it a trailing run of 0x00's?
*/
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size)
{
//errno = ENOSPC;
return (NULL);
}
//return strcpy(dst, tmp);
return ex_strcpy(dst, size, tmp);
//return (NULL);
static const char * _inet_ntop_v6(const ex_u8 *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[EX_IPV6_NAME_LEN];
char *tp;
struct {
long base;
long len;
} best, cur;
u_long words[IN6ADDRSZ / INT16SZ];
int i;
/* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, 0, sizeof(words));
for (i = 0; i < IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
if (words[i] == 0)
{
if (cur.base == -1) {
cur.base = i;
cur.len = 1;
}
else{
cur.len++;
}
}
else if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
best = cur;
if (best.base != -1 && best.len < 2)
best.base = -1;
/* Format the result.
*/
tp = tmp;
size_t tmp_size = 0;
size_t offset = 0;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
/* Are we inside the best run of 0x00's?
*/
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base) {
*tp++ = ':';
offset += 1;
}
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if (i != 0) {
*tp++ = ':';
offset += 1;
}
/* Is this address an encapsulated IPv4?
*/
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!_inet_ntop_v4(src + 12, tp, sizeof(tmp) - (tp - tmp)))
{
//errno = ENOSPC;
return (NULL);
}
tmp_size = strlen(tp);
tp += tmp_size;
offset += tmp_size;
break;
}
//tp += ex_strformat(tp, "%lX", words[i]);
tmp_size = ex_strformat(tp, EX_IPV6_NAME_LEN-offset, "%lX", words[i]);
tp += tmp_size;
offset += tmp_size;
}
/* Was it a trailing run of 0x00's?
*/
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size)
{
//errno = ENOSPC;
return (NULL);
}
//return strcpy(dst, tmp);
return ex_strcpy(dst, size, tmp);
//return (NULL);
}
const char* ex_inet_ntop(int af, const void *src, char *dst, size_t size) {
switch (af) {
case AF_INET:
return _inet_ntop_v4(src, dst, size);
case AF_INET6:
return _inet_ntop_v6((const ex_u8*)src, dst, size);
default:
errno = EAFNOSUPPORT;
return NULL;
}
}
const char* ex_inet_ntop(int af, const void *src, char *dst, size_t size) {
switch (af) {
case AF_INET:
return _inet_ntop_v4(src, dst, size);
case AF_INET6:
return _inet_ntop_v6((const ex_u8*)src, dst, size);
default:
errno = EAFNOSUPPORT;
return NULL;
}
}
int ex_ip4_name(const struct sockaddr_in *src, char *dst, size_t size) {
if (NULL == _inet_ntop_v4((const unsigned char *)&(src->sin_addr), dst, size))
return -1;