-
Notifications
You must be signed in to change notification settings - Fork 41
Some changes to fix the path problem under windows system and android TAK client #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kbtxwer
wants to merge
5
commits into
kdudkov:master
Choose a base branch
from
kbtxwer:mission_package_api_fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aee6adf
1. improve the body limit so that it can be able to send large files
d07dd62
1. use path unescape for webtak because there are some space in the f…
d07dada
feature: a simple implementation of Federation Service, may cause Bro…
1f985e6
feature: a simple solution to avoid board cast storm and also transfe…
6cdd356
pull down all the online css,js,font resources to local to speed up l…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/kdudkov/goatak/internal/client" | ||
| "log/slog" | ||
| "sync" | ||
| "time" | ||
| ) | ||
|
|
||
| // ConnectToFedServer 这是Fed服务器,只应该从服务器获取信息,但不要发送任何信息过去 | ||
| func (app *App) ConnectToFedServer(ctx context.Context, fed *FedConfig) { | ||
| for ctx.Err() == nil { | ||
| addr := fmt.Sprintf("%s:%d:%s", fed.Host, fed.Port, fed.Proto) // localhost:8087:tcp | ||
| conn, err := app.connect(addr) | ||
| if err != nil { | ||
| app.logger.Error("Fed Server connect error", slog.Any("error", err)) | ||
| time.Sleep(time.Second * 5) | ||
| continue | ||
| } | ||
|
|
||
| fedName := fmt.Sprintf("fed_%s:%v", fed.Host, fed.Port) | ||
| app.logger.Info(fmt.Sprintf("Federation to %s connected", fedName)) | ||
|
|
||
| wg := &sync.WaitGroup{} | ||
| wg.Add(1) | ||
|
|
||
| h := client.NewConnClientHandler(addr, conn, &client.HandlerConfig{ | ||
| MessageCb: app.NewCotMessage, | ||
| RemoveCb: func(ch client.ClientHandler) { | ||
| wg.Done() | ||
| app.handlers.Delete(addr) | ||
| app.logger.Info("disconnected") | ||
| }, | ||
| NewContactCb: app.NewContactCb, | ||
| Name: fedName, | ||
| DisableSend: true, | ||
| IsClient: true, | ||
| UID: app.uid, | ||
| }) | ||
|
|
||
| go h.Start() | ||
| app.AddClientHandler(h) | ||
|
|
||
| wg.Wait() | ||
| } | ||
| } | ||
|
|
||
| func (app *App) connToFed(ctx context.Context, fed *FedConfig) error { | ||
| app.ConnectToFedServer(ctx, fed) | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/kdudkov/goatak/internal/client" | ||
| "log/slog" | ||
| "net" | ||
| "strings" | ||
| ) | ||
|
|
||
| // fed server 作为服务器,主要工作是为客户端提供数据,但客户端不会向服务端传输数据,如有此需求应当配置双向连接 | ||
|
|
||
| func (app *App) ListenTcpFed(ctx context.Context, addr string) (err error) { | ||
| app.logger.Info("listening TCP Federation at " + addr) | ||
| defer func() { | ||
| if r := recover(); r != nil { | ||
| app.logger.Error("panic in ListenTCP", slog.Any("error", r)) | ||
| } | ||
| }() | ||
|
|
||
| listener, err := net.Listen("tcp", addr) | ||
| if err != nil { | ||
| app.logger.Error("Failed to listen", slog.Any("error", err)) | ||
|
|
||
| return err | ||
| } | ||
|
|
||
| defer listener.Close() | ||
|
|
||
| for ctx.Err() == nil { | ||
| conn, err := listener.Accept() | ||
| if err != nil { | ||
| app.logger.Error("Unable to accept connections", slog.Any("error", err)) | ||
|
|
||
| return err | ||
| } | ||
|
|
||
| remoteAddr := conn.RemoteAddr().String() | ||
| localAddr := conn.LocalAddr().String() | ||
| app.logger.Info("TCP Federation connection from " + remoteAddr) | ||
| h := client.NewConnClientHandler( | ||
| conn.RemoteAddr().Network()+"_"+remoteAddr, | ||
| conn, &client.HandlerConfig{ | ||
| // 创建一个处理客户端请求的功能,不要接收来自它的消息,但需要把消息发给它 | ||
| MessageCb: app.DummyHandler, | ||
| RemoveCb: app.RemoveHandlerCb, | ||
| NewContactCb: app.NewContactCb, | ||
| DropMetric: dropMetric, | ||
| DisableRecv: true, | ||
| Name: fmt.Sprintf("fed_%s:%v", strings.Split(remoteAddr, ":")[0], strings.Split(localAddr, ":")[1]), | ||
| }) | ||
| app.AddClientHandler(h) | ||
| h.Start() | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to use /webtak handle at all if it's not a webtacRoot