Coder Social home page Coder Social logo

mojocn / felix Goto Github PK

View Code? Open in Web Editor NEW
838.0 25.0 179.0 14.74 MB

A Friendly SSH Jumper Bastion Fortress Server

Home Page: https://mojotv.cn/golang/golang-terminl-util-felix

License: Apache License 2.0

Go 100.00%
ssh gin-gonic gorm scaffold goalng restful backend terminal scp pewdiepie

felix's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

felix's Issues

ws_ssh_term.go文件中63-67行的代码功能是什么?我注释掉后正常能ssh到指定服务器

	client, err := flx.NewSshClient(mc)
	if wshandleError(wsConn, err) {
		return
	}
	defer client.Close()
	startTime := time.Now()
        //下面注释的这段代码功能是什么?我注释掉后还是正常能ssh到指定服务器
	//ssConn, err := util.NewSshConn(cols, rows, client)
	//if wshandleError(wsConn, err) {
	//	return
	//}
	//defer ssConn.Close()
	sws, err := model.NewLogicSshWsSession(cols, rows, true, client, wsConn)
	if wshandleError(wsConn, err) {
		return
	}
	defer sws.Close()

	quitChan := make(chan bool, 3)
	sws.Start(quitChan)
	go sws.Wait(quitChan)

Is the felixbin code available ?

Hey guys,

Great job, with felix !
I was wondering if the felixbin code which is in the zipdata was available.
And if not I wanted to know how you done the conversion to zipdata.

Thanks a lot !

命令的结果输出是原命令,而不是命令执行结果;

`package main

import (
"bufio"
"bytes"
"fmt"
"github.com/gin-gonic/gin"
"github.com/mitchellh/go-homedir"
"io/ioutil"
"log"
"os"
"strconv"
"strings"
"time"

"encoding/base64"
"encoding/json"
"github.com/gorilla/websocket"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
"io"
"net/http"
"sync"

)

const (
wsMsgCmd = "cmd"
wsMsgResize = "resize"
)

type wsMsg struct {
Type string json:"type"
Cmd string json:"cmd"
Cols int json:"cols"
Rows int json:"rows"
}

// copy data from WebSocket to ssh server
// and copy data from ssh server to WebSocket

// write data to WebSocket
// the data comes from ssh server.
type wsBufferWriter struct {
buffer bytes.Buffer
mu sync.Mutex
}

// implement Write interface to write bytes from ssh server into bytes.Buffer.
func (w *wsBufferWriter) Write(p []byte) (int, error) {
w.mu.Lock()
defer w.mu.Unlock()
return w.buffer.Write(p)
}

func NewSshClient() (*ssh.Client, error) {
config := &ssh.ClientConfig{
Timeout: time.Second * 50000,
User: "root",
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //这个可以, 但是不够安全
//HostKeyCallback: hostKeyCallBackFunc("192.168.96.109"),
}
config.Auth = []ssh.AuthMethod{ssh.Password("cp123456")}
//config.Auth = []ssh.AuthMethod{publicKeyAuthFunc(h.Key)}
//addr := fmt.Sprintf("%s:%d", h.Host, h.Port)
addr := "192.168.96.109:22"
c, err := ssh.Dial("tcp", addr, config)
if err != nil {
return nil, err
}
return c, nil
}
func hostKeyCallBackFunc(host string) ssh.HostKeyCallback {
hostPath, err := homedir.Expand("~/.ssh/known_hosts")
if err != nil {
log.Fatal("find known_hosts's home dir failed", err)
}
file, err := os.Open(hostPath)
if err != nil {
log.Fatal("can't find known_host file:", err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
var hostKey ssh.PublicKey
for scanner.Scan() {
fields := strings.Split(scanner.Text(), " ")
if len(fields) != 3 {
continue
}
if strings.Contains(fields[0], host) {
var err error
hostKey, _, _, _, err = ssh.ParseAuthorizedKey(scanner.Bytes())
if err != nil {
log.Fatalf("error parsing %q: %v", fields[2], err)
}
break
}
}
if hostKey == nil {
log.Fatalf("no hostkey for %s,%v", host, err)
}
return ssh.FixedHostKey(hostKey)
}

func publicKeyAuthFunc(kPath string) ssh.AuthMethod {
keyPath, err := homedir.Expand(kPath)
if err != nil {
log.Fatal("find key's home dir failed", err)
}
key, err := ioutil.ReadFile(keyPath)
if err != nil {
log.Fatal("ssh key file read failed", err)
}
// Create the Signer for this private key.
signer, err := ssh.ParsePrivateKey(key)
if err != nil {
log.Fatal("ssh key signer failed", err)
}
return ssh.PublicKeys(signer)
}
func runCommand(client *ssh.Client, command string) (stdout string, err error) {
session, err := client.NewSession()
if err != nil {
//log.Print(err)
return
}
defer session.Close()

var buf bytes.Buffer
session.Stdout = &buf
err = session.Run(command)
if err != nil {
    //log.Print(err)
    return
}
stdout = string(buf.Bytes())

return

}

// connect to ssh server using ssh session.
type SshConn struct {
// calling Write() to write data into ssh server
StdinPipe io.WriteCloser
// Write() be called to receive data from ssh server
ComboOutput *wsBufferWriter
Session *ssh.Session
}

//flushComboOutput flush ssh.session combine output into websocket response
func flushComboOutput(w *wsBufferWriter, wsConn *websocket.Conn) error {
if w.buffer.Len() != 0 {
fmt.Println(string(w.buffer.Bytes()))
err := wsConn.WriteMessage(websocket.TextMessage, w.buffer.Bytes())
if err != nil {
return err
}
w.buffer.Reset()
}
return nil
}
// setup ssh shell session
// set Session and StdinPipe here,
// and the Session.Stdout and Session.Sdterr are also set.
func NewSshConn(cols, rows int, sshClient *ssh.Client) (*SshConn, error) {
sshSession, err := sshClient.NewSession()
if err != nil {
fmt.Println("NewSession failed; msg:", err)
return nil, err
}

// we set stdin, then we can write data to ssh server via this stdin.
// but, as for reading data from ssh server, we can set Session.Stdout and Session.Stderr
// to receive data from ssh server, and write back to somewhere.
stdinP, err := sshSession.StdinPipe()
if err != nil {
    return nil, err
}

comboWriter := new(wsBufferWriter)
//ssh.stdout and stderr will write output into comboWriter
sshSession.Stdout = comboWriter
sshSession.Stderr = comboWriter

modes := ssh.TerminalModes{
    ssh.ECHO:          1,     // disable echo
    ssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
    ssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
}
// Request pseudo terminal
if err := sshSession.RequestPty("xterm", rows, cols, modes); err != nil {
    fmt.Println("RequestPty failed; msg: ", err.Error())
    return nil, err
}
// Start remote shell
if err := sshSession.Shell(); err != nil {
    fmt.Println("ssh.Shell failed; msg:", err.Error())
    return nil, err
}
return &SshConn{StdinPipe: stdinP, ComboOutput: comboWriter, Session: sshSession}, nil

}
func (s *SshConn) Close() {
if s.Session != nil {
s.Session.Close()
}
}
//ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin
func (ssConn *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff bytes.Buffer, exitCh chan bool) {
//tells other go routine quit
defer setQuit(exitCh)
for {
select {
case <-exitCh:
return
default:
//read websocket msg
_, wsData, err := wsConn.ReadMessage()
if err != nil {
logrus.WithError(err).Error("reading webSocket message failed")
return
}
//unmashal bytes into struct
msgObj := wsMsg{}
if err := json.Unmarshal(wsData, &msgObj); err != nil {
logrus.WithError(err).WithField("wsData", string(wsData)).Error("unmarshal websocket message failed")
}
switch msgObj.Type {
case wsMsgResize:
//handle xterm.js size change
if msgObj.Cols > 0 && msgObj.Rows > 0 {
if err := ssConn.Session.WindowChange(msgObj.Rows, msgObj.Cols); err != nil {
logrus.WithError(err).Error("ssh pty change windows size failed")
}
}
case wsMsgCmd:
//handle xterm.js stdin
decodeBytes, err := base64.StdEncoding.DecodeString(msgObj.Cmd)
if err != nil {
logrus.WithError(err).Error("websock cmd string base64 decoding failed")
}
//if _, err := ssConn.StdinPipe.Write(decodeBytes); err != nil {
if _, err := ssConn.StdinPipe.Write(decodeBytes); err != nil {
logrus.WithError(err).Error("ws cmd bytes write to ssh.stdin pipe failed")
}
/

//write input cmd to log buffer
if _, err := logBuff.Write(decodeBytes); err != nil {
logrus.WithError(err).Error("write received cmd into log buffer failed")
}
*/
}
}
}
}

func (ssConn *SshConn) SendComboOutput(wsConn *websocket.Conn, exitCh chan bool) {
//tells other go routine quit
defer setQuit(exitCh)

//every 120ms write combine output bytes into websocket response
tick := time.NewTicker(time.Millisecond * time.Duration(120))
//for range time.Tick(120 * time.Millisecond){}
defer tick.Stop()
for {
    select {
    case <-tick.C:
        //write combine output bytes into websocket response
        if err := flushComboOutput(ssConn.ComboOutput, wsConn); err != nil {
            logrus.WithError(err).Error("ssh sending combo output to webSocket failed")
            return
        }
    case <-exitCh:
        return
    }
}

}

func (ssConn *SshConn) SessionWait(quitChan chan bool) {
if err := ssConn.Session.Wait(); err != nil {
logrus.WithError(err).Error("ssh session wait failed")
setQuit(quitChan)
}
}

func setQuit(ch chan bool) {
ch <- true
}

func web(c *gin.Context) {
//打印请求的方法
c.JSON(http.StatusOK, gin.H{"msg": "请求已提交", "status": 0})
//c.HTML(http.StatusOK, "websocket.html", gin.H{"title": "Posts"})
}

var upGrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024 * 1024 * 10,
CheckOrigin: func(r *http.Request) bool {
return true
},
}

// handle webSocket connection.
// first,we establish a ssh connection to ssh server when a webSocket comes;
// then we deliver ssh data via ssh connection between browser and ssh server.
// That is, read webSocket data from browser (e.g. 'ls' command) and send data to ssh server via ssh connection;
// the other hand, read returned ssh data from ssh server and write back to browser via webSocket API.
func WsSsh(c *gin.Context) {
fmt.Println("Wsssh...")
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
fmt.Printf("upGrader failed; msg: %s", err.Error())
}
defer wsConn.Close()

cols, err := strconv.Atoi(c.DefaultQuery("cols", "120"))
if err != nil {
    fmt.Printf("Atoi failed; msg: %s", err.Error())
}
rows, err := strconv.Atoi(c.DefaultQuery("rows", "32"))
if err != nil {
    fmt.Printf("Atoi failed; msg: %s", err.Error())
}
client, err := NewSshClient()
if err != nil {
    fmt.Printf("NewSshClient failed; msg: %s", err.Error())
}
defer client.Close()
ssConn, err := NewSshConn(cols, rows, client)
if err != nil {
    fmt.Printf("NewSshConn failed; msg: %s", err.Error())
}
defer ssConn.Close()

quitChan := make(chan bool, 3)

var logBuff = new(bytes.Buffer)

// most messages are ssh output, not webSocket input
go ssConn.ReceiveWsMsg(wsConn, logBuff, quitChan)
go ssConn.SendComboOutput(wsConn, quitChan)
go ssConn.SessionWait(quitChan)

<-quitChan

logrus.Info("websocket finished")

}

func InitRouter() *gin.Engine {
r := gin.New()
//http.Handle("/web/ssh", websocket.Handler(WsSsh))
r.GET("/web/ssh", WsSsh)
r.GET("/web", web)
return r
}

func main() {
r := gin.New()
r.GET("/web/ssh", WsSsh)
r.GET("/web", web)
gin.SetMode(gin.DebugMode)

//接受websocket的路由地址
s := &http.Server{
    Addr:           ":12345",
    Handler:        r,
    ReadTimeout:    60 * time.Second,
    WriteTimeout:   60 * time.Second,
    MaxHeaderBytes: 1 << 20,
}

if err := s.ListenAndServe(); err != nil {
    fmt.Printf("ListenAndServe failed; msg: %s", err.Error())
}

}
`
websocket测试地址:
http://www.bejson.com/httputil/websocket/

测试命令:
{"type": "cmd", "cmd": "L2Jpbi9scyUyMC9yb290JTBB", "cols": 20, "rows": 20}

命令的结果输出是原命令,而不是命令执行结果;
麻烦大佬帮忙看下

执行felix sshw启动报错

root@debian:/opt/goproject/src/github.com/dejavuzhou/felix# felix sshw
panic: interface conversion: interface {} is string, not []uint8 [recovered]
panic: interface conversion: interface {} is string, not []uint8

goroutine 1 [running]:
github.com/jinzhu/gorm.(*Scope).callCallbacks.func1(0xc00016d900)
/opt/goproject/src/github.com/jinzhu/gorm/scope.go:884 +0xb0
panic(0xc85400, 0xc00018d080)
/opt/soft/go/src/runtime/panic.go:522 +0x1b5
github.com/dejavuzhou/felix/models.(*JsonArrayUint).Scan(0xc00008c560, 0xc37ce0, 0xc0003f0d30, 0x7ff00783d238, 0xc00008c560)
/opt/goproject/src/github.com/dejavuzhou/felix/models/j_array_uint.go:16 +0xa3
database/sql.convertAssignRows(0xcc2d20, 0xc00008c560, 0xc37ce0, 0xc0003f0d30, 0xc00016da00, 0xc00008c560, 0x0)
/opt/soft/go/src/database/sql/convert.go:378 +0x189a
database/sql.convertAssignRows(0xc000066a00, 0xc000010aa0, 0xc37ce0, 0xc0003f0d30, 0xc00016da00, 0x0, 0x0)
/opt/soft/go/src/database/sql/convert.go:421 +0xf2f
database/sql.(*Rows).Scan(0xc00016da00, 0xc0000c22a0, 0xe, 0xe, 0xc000074798, 0xc000010aa0)
/opt/soft/go/src/database/sql/sql.go:2955 +0x212
github.com/jinzhu/gorm.(*Scope).scan(0xc00016d900, 0xc00016da00, 0xc0000c2000, 0xe, 0xe, 0xc00016db00, 0xf, 0x10)
/opt/goproject/src/github.com/jinzhu/gorm/scope.go:532 +0x55b
github.com/jinzhu/gorm.queryCallback(0xc00016d900)
/opt/goproject/src/github.com/jinzhu/gorm/callback_query.go:79 +0x5f8
github.com/jinzhu/gorm.(*Scope).callCallbacks(0xc00016d900, 0xc0001a1520, 0x3, 0x4, 0x0)
/opt/goproject/src/github.com/jinzhu/gorm/scope.go:888 +0x88
github.com/jinzhu/gorm.(*DB).First(0xc0003e7110, 0xcec7e0, 0xc0001aae10, 0x0, 0x0, 0x0, 0xc68ce0)
/opt/goproject/src/github.com/jinzhu/gorm/main.go:331 +0x128
github.com/jinzhu/gorm.(*DB).FirstOrCreate(0xc0003e7110, 0xcec7e0, 0xc0001aae10, 0x0, 0x0, 0x0, 0xc0003e7110)
/opt/goproject/src/github.com/jinzhu/gorm/main.go:425 +0x9c
github.com/dejavuzhou/felix/models.(*User).CreateInitUser(0xc0001aae10, 0xc0001aae10, 0x9)
/opt/goproject/src/github.com/dejavuzhou/felix/models/m_users.go:107 +0xfd
github.com/dejavuzhou/felix/models.CreateSqliteDB(0x0)
/opt/goproject/src/github.com/dejavuzhou/felix/models/db.go:41 +0x5a8
github.com/dejavuzhou/felix/cmd.initFunc()
/opt/goproject/src/github.com/dejavuzhou/felix/cmd/root.go:53 +0x2c
github.com/spf13/cobra.(*Command).preRun(0x1861240)
/opt/goproject/src/github.com/spf13/cobra/command.go:856 +0x49
github.com/spf13/cobra.(*Command).execute(0x1861240, 0x18ca6c8, 0x0, 0x0, 0x1861240, 0x18ca6c8)
/opt/goproject/src/github.com/spf13/cobra/command.go:792 +0x146
github.com/spf13/cobra.(*Command).ExecuteC(0x185ecc0, 0xc000021200, 0x18a9680, 0x0)
/opt/goproject/src/github.com/spf13/cobra/command.go:914 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
/opt/goproject/src/github.com/spf13/cobra/command.go:864
github.com/dejavuzhou/felix/cmd.Execute(0x0, 0x0, 0x0, 0x0)
/opt/goproject/src/github.com/dejavuzhou/felix/cmd/root.go:37 +0x7c
main.main()
/opt/goproject/src/github.com/dejavuzhou/felix/main.go:8 +0x51

felix sshw 报错

`felix sshw
panic: interface conversion: interface {} is string, not []uint8 [recovered]
panic: interface conversion: interface {} is string, not []uint8

goroutine 1 [running]:
github.com/jinzhu/gorm.(*Scope).callCallbacks.func1(0xc0006a3200)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/scope.go:884 +0xb3
panic(0x48ac640, 0xc0006b4600)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/dejavuzhou/felix/models.(*JsonArrayUint).Scan(0xc0001518c0, 0x485fd00, 0xc000069840, 0x6294200, 0xc0001518c0)
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/models/j_array_uint.go:16 +0xa3
database/sql.convertAssign(0x4901cc0, 0xc0001518c0, 0x485fd00, 0xc000069840, 0xc0001518c0, 0x16)
/usr/local/Cellar/go/1.11/libexec/src/database/sql/convert.go:341 +0x17c8
database/sql.convertAssign(0xc0001ccbc0, 0xc000444eb0, 0x485fd00, 0xc000069840, 0x0, 0x0)
/usr/local/Cellar/go/1.11/libexec/src/database/sql/convert.go:384 +0xc14
database/sql.(*Rows).Scan(0xc0006a3300, 0xc000128400, 0x10, 0x10, 0xc0000ac0b0, 0x16)
/usr/local/Cellar/go/1.11/libexec/src/database/sql/sql.go:2932 +0x1e7
github.com/jinzhu/gorm.(*Scope).scan(0xc0006a3200, 0xc0006a3300, 0xc00044df00, 0x10, 0x10, 0xc000128300, 0x11, 0x20)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/scope.go:532 +0x499
github.com/jinzhu/gorm.queryCallback(0xc0006a3200)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/callback_query.go:79 +0x523
github.com/jinzhu/gorm.(*Scope).callCallbacks(0xc0006a3200, 0xc0001c7600, 0x3, 0x4, 0x0)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/scope.go:888 +0x88
github.com/jinzhu/gorm.(*DB).First(0xc0006aaea0, 0x4911ba0, 0xc000691c20, 0x0, 0x0, 0x0, 0x48909c0)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/main.go:331 +0x10d
github.com/jinzhu/gorm.(*DB).FirstOrCreate(0xc0006aaea0, 0x4911ba0, 0xc000691c20, 0x0, 0x0, 0x0, 0xc0006aaea0)
/Users/yxs/GolandProjects/src/github.com/jinzhu/gorm/main.go:425 +0x9c
github.com/dejavuzhou/felix/models.(*User).CreateInitUser(0xc000691c20, 0xc000691c20, 0xa)
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/models/m_users.go:105 +0x105
github.com/dejavuzhou/felix/models.CreateSqliteDB(0x0)
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/models/db.go:41 +0x532
github.com/dejavuzhou/felix/cmd.initFunc()
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/cmd/root.go:53 +0x2c
github.com/spf13/cobra.(*Command).preRun(0x51fd020)
/Users/yxs/GolandProjects/src/github.com/spf13/cobra/command.go:856 +0x49
github.com/spf13/cobra.(*Command).execute(0x51fd020, 0x522d938, 0x0, 0x0, 0x51fd020, 0x522d938)
/Users/yxs/GolandProjects/src/github.com/spf13/cobra/command.go:792 +0x148
github.com/spf13/cobra.(*Command).ExecuteC(0x51faaa0, 0xc0000e3f58, 0x46bfe81, 0xc00044d100)
/Users/yxs/GolandProjects/src/github.com/spf13/cobra/command.go:914 +0x2f8
github.com/spf13/cobra.(*Command).Execute(0x51faaa0, 0xc0000e3f58, 0x46bff6e)
/Users/yxs/GolandProjects/src/github.com/spf13/cobra/command.go:864 +0x2b
github.com/dejavuzhou/felix/cmd.Execute(0x0, 0x0, 0x0, 0x0)
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/cmd/root.go:37 +0x77
main.main()
/Users/yxs/GolandProjects/src/github.com/dejavuzhou/felix/main.go:8 +0x51
`

另外找到相同的问题 #5
没有felix flush 这个指令
felix flush
Error: unknown command "flush" for "felix"
Run 'felix --help' for usage.
unknown command "flush" for "felix"

使用Postgresql生成的代码运行报错

func createDatabase() (*gorm.DB, error) {
	dbType := config.GetString("db.type")
	dbAddr := config.GetString("db.addr")
	dbName := config.GetString("db.database")
	dbUser := config.GetString("db.user")
	dbPassword := config.GetString("db.password")
	dbCharset := config.GetString("db.charset")
	conn := ""
	switch dbType {
	case "mysql":
		conn = fmt.Sprintf("%s:%s@(%s)/%s?charset=%s&parseTime=True&loc=Local", dbUser, dbPassword, dbAddr, dbName, dbCharset)
	case "sqlite":
		conn = dbAddr
	case "mssql":
		return nil, errors.New("TODO:suport sqlServer")
	case "postgres":
		hostPort := strings.Split(dbAddr, ":")
		if len(hostPort) == 2 {
			return nil, errors.New("db.addr must be like this host:ip")
		}
		conn = fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s sslmode=disable", hostPort[0], hostPort[1], dbUser, dbName, dbPassword)
	default:
		return nil, fmt.Errorf("database type %s is not supported by felix ginrbo", dbType)
	}
	return gorm.Open(dbType, conn)
}

其中的

if len(hostPort) == 2 {
			return nil, errors.New("db.addr must be like this host:ip")
		}

应该是len(hostPort) != 2

传输文件报错

可以连接服务器了,但传输文件报错
好像报数据库的错误

[install error]macOS 10.13 github.com/jinzhu/gorm/dialects/sqlite

  • env
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G702
go version go1.11.4 darwin/amd64
gcc -v                                                                                                                                                                                                    
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • error info
 $ go install -v -a
github.com/dejavuzhou/felix/utils
# github.com/mattn/go-sqlite3
sqlite3-binding.c:18709:17: warning: 'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in macOS 10.12 - Use atomic_compare_exchange_strong() from <stdatomic.h> instead [-Wdeprecated-declarations]
/usr/include/libkern/OSAtomicDeprecated.h:547:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly marked deprecated here
# github.com/dejavuzhou/felix/utils
utils/ssh_shell_conn.go:134:30: ssConn.Session.WindowChange undefined (type *ssh.Session has no field or method WindowChange)

启动提示找不到配置文件

环境win10;go版本 1.1.7

time="2022-05-05T16:29:53+08:00" level=fatal msg="Fatal error config file: Config File "config" Not Found in "[D:\\go_project\\felix2 D:\\etc\\felix C:\\Users\\Administrator\\.felix]" \n"

go get error

go get: github.com/libragen/[email protected]: parsing go.mod:
module declares its path as: github.com/dejavuzhou/felix
but was required as: github.com/libragen/felix

model db.CreateUserOfRole undefined

felix ginbro --dbAddr "X.X.X.X:YYYY" --dbName mydbname --dbPassword "mydbpass" --dbType mysql --dbUser mydbuser --dir myoutputdirectory --pkg mypackagename -V

produces:

2020/11/29 10:14:59 SQLite3 in: /home/ubuntu/.felix/sqlite.db
cd mypackagename then run go run main.go test your codebase

running: go run main.go
model/m_info_flags.go:50:11: db.CreateUserOfRole undefined (type *gorm.DB has no field or method CreateUserOfRole)
model/m_info_stats.go:62:11: db.CreateUserOfRole undefined (type *gorm.DB has no field or method CreateUserOfRole)
model/m_time_stats.go:61:11: db.CreateUserOfRole undefined (type *gorm.DB has no field or method CreateUserOfRole)
model/m_network_stats.go:61:11: db.CreateUserOfRole undefined (type *gorm.DB has no field or method CreateUserOfRole)
model/m_network_stats.go:61:11: too many errors

找不到config

看了一下readme,感觉像是要自己配个config ?
我用docker(golang:1.13)直接按照编译和运行的流程后,执行felix sshw出现:

FATA[0000] Fatal error config file: Config File "config" Not Found in "[/go/src/github.com/libragen/felix /etc/felix /root/.felix]"

是程序出错了还是需要自己配个config还是?
如果需要配置个config,能否直接提供一份default config在代码中,一开始要额外编辑,对docker玩家有点难受呀。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.