6-7
This commit is contained in:
@@ -82,6 +82,9 @@ var pingTimes = [][]float64{}
|
||||
|
||||
var xmlLog *os.File
|
||||
|
||||
// Basic roster
|
||||
var Roster = make(map[string]bool)
|
||||
|
||||
func init() {
|
||||
beeep.AppName = loadedLocale["appName"]
|
||||
|
||||
@@ -98,7 +101,6 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
pingTimes = append(pingTimes, []float64{})
|
||||
p, err := ensureConfig()
|
||||
if err != nil {
|
||||
@@ -132,6 +134,11 @@ func main() {
|
||||
xmlLog = os.Stdout
|
||||
}
|
||||
|
||||
res := "/" + loadedConfig.Resource
|
||||
if loadedConfig.RandomizeResource {
|
||||
res = ""
|
||||
}
|
||||
|
||||
config := xmpp.Config{
|
||||
TransportConfiguration: xmpp.TransportConfiguration{
|
||||
Address: loadedConfig.Server,
|
||||
@@ -141,7 +148,7 @@ func main() {
|
||||
ConnectTimeout: 300,
|
||||
TLSConfig: &tls.Config{InsecureSkipVerify: loadedConfig.Insecure},
|
||||
},
|
||||
Jid: loadedConfig.Username + "/" + loadedConfig.Resource,
|
||||
Jid: loadedConfig.Username + res,
|
||||
Credential: xmpp.Password(loadedConfig.Password),
|
||||
Insecure: loadedConfig.Insecure,
|
||||
StreamManagementEnable: true,
|
||||
@@ -161,6 +168,29 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// All requests from either ourselves or our server will always be accepted regardless of user settings.
|
||||
|
||||
|
||||
if !(loadedConfig.DiscoPrivacy == 0) && !((JidMustParse(iq.From).Bare() == JidMustParse(clientroot.Session.BindJid).Bare()) || (JidMustParse(iq.From).Domain == JidMustParse(clientroot.Session.BindJid).Domain)) {
|
||||
if loadedConfig.DiscoPrivacy == None || (loadedConfig.DiscoPrivacy == OnlyRoster && !Roster[JidMustParse(iq.From).Bare()]) {
|
||||
fmt.Println("blocking", loadedConfig.DiscoPrivacy)
|
||||
if loadedConfig.IgnoreInsteadOfReturnErrorUponPrivacyViolation {
|
||||
return
|
||||
}
|
||||
|
||||
iqResp.Type = "error"
|
||||
|
||||
stanza_err := new(stanza.Err)
|
||||
stanza_err.Type = stanza.ErrorTypeCancel
|
||||
stanza_err.Text = "service-unavailable"
|
||||
|
||||
iqResp.MakeError(*stanza_err)
|
||||
s.Send(iqResp)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
identity := stanza.Identity{
|
||||
Name: "Lambda",
|
||||
Category: "client", // TODO: Allow spoofing on user request
|
||||
@@ -182,6 +212,8 @@ func main() {
|
||||
{Var: "urn:xmpp:attention:0"},
|
||||
{Var: "urn:xmpp:carbons:2"},
|
||||
{Var: "urn:xmpp:ping"},
|
||||
{Var: "jabber:iq:oob"},
|
||||
{Var: "jabber:x:oob"},
|
||||
},
|
||||
}
|
||||
iqResp.Payload = &payload
|
||||
@@ -192,7 +224,6 @@ func main() {
|
||||
iq, ok := p.(*stanza.IQ)
|
||||
if !ok || iq.Type != stanza.IQTypeGet {
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
iqResp, err := stanza.NewIQ(stanza.Attrs{Type: "result", From: iq.To, To: iq.From, Id: iq.Id})
|
||||
@@ -200,6 +231,27 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// All requests from either ourselves or our server will always be accepted regardless of user settings.
|
||||
|
||||
if !(loadedConfig.VersionPrivacy == 0) && !((JidMustParse(iq.From).Bare() == JidMustParse(clientroot.Session.BindJid).Bare()) || (JidMustParse(iq.From).Domain == JidMustParse(clientroot.Session.BindJid).Domain)) {
|
||||
if loadedConfig.VersionPrivacy == None || (loadedConfig.VersionPrivacy == OnlyRoster && !Roster[JidMustParse(iq.From).Bare()]) {
|
||||
fmt.Println("blocking", loadedConfig.DiscoPrivacy)
|
||||
if loadedConfig.IgnoreInsteadOfReturnErrorUponPrivacyViolation {
|
||||
return
|
||||
}
|
||||
|
||||
iqResp.Type = "error"
|
||||
|
||||
stanza_err := new(stanza.Err)
|
||||
stanza_err.Type = stanza.ErrorTypeCancel
|
||||
stanza_err.Text = "service-unavailable"
|
||||
|
||||
iqResp.MakeError(*stanza_err)
|
||||
s.Send(iqResp)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
v := &stanza.Version{}
|
||||
v = v.SetInfo(loadedLocale["appName"], lambda_version, runtime.GOOS) // TODO: Allow spoofing on user request
|
||||
|
||||
@@ -484,37 +536,6 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Throughput
|
||||
/*
|
||||
var oldsize int64
|
||||
var newsize int64
|
||||
var diff float64
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(5 * time.Second)
|
||||
stat, err := xmlLog.Stat()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
newsize = stat.Size()
|
||||
diff = float64(newsize-oldsize) / 1000
|
||||
|
||||
ic := clientAssets["car"]
|
||||
if diff >= 25 {
|
||||
ic = clientAssets["car_high"]
|
||||
}
|
||||
|
||||
glib.IdleAdd(func() {
|
||||
sStatus.SetText(fmt.Sprintf("%.2f%s", diff, loadedLocale["KBPerSecond"]))
|
||||
sIcon.SetFromPaintable(ic)
|
||||
})
|
||||
|
||||
oldsize = newsize
|
||||
}
|
||||
}()
|
||||
*/
|
||||
|
||||
glib.IdleAdd(func() {
|
||||
connectionStatus.SetText(fmt.Sprintf("%s%s", loadedLocale["connectedAs"], JidMustParse(clientroot.Session.BindJid).Bare()))
|
||||
connectionStatus.SetTooltipText(fmt.Sprintf("%s%s\n%s%t", loadedLocale["bindedJid"], clientroot.Session.BindJid, loadedLocale["usingTLS"], clientroot.Session.TlsEnabled))
|
||||
@@ -583,6 +604,7 @@ func main() {
|
||||
for _, v := range items.Items {
|
||||
name := v.Name
|
||||
jid := v.Jid
|
||||
Roster[jid] = true
|
||||
|
||||
if name == "" {
|
||||
name = jid
|
||||
@@ -613,13 +635,13 @@ func main() {
|
||||
go getAvatar(jid, jid, im)
|
||||
/*
|
||||
|
||||
go func() {
|
||||
new_im := getAvatar(jid, jid) // TODO: Use PEP avatar and do not use JID as hash
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
new_im := getAvatar(jid, jid) // TODO: Use PEP avatar and do not use JID as hash
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
*/
|
||||
|
||||
box.AddController(gesture1)
|
||||
@@ -710,13 +732,13 @@ func main() {
|
||||
|
||||
go getAvatar(jid, jid, im)
|
||||
/*
|
||||
go func() {
|
||||
new_im := getAvatar(jid, jid)
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
new_im := getAvatar(jid, jid)
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
*/
|
||||
|
||||
box.AddController(gesture1)
|
||||
@@ -1014,13 +1036,13 @@ func activate(app *gtk.Application) {
|
||||
|
||||
go getAvatar(t, t, im)
|
||||
/*
|
||||
go func() {
|
||||
new_im := getAvatar(t, t)
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
new_im := getAvatar(t, t)
|
||||
glib.IdleAdd(func() {
|
||||
new_im.SetPixelSize(40)
|
||||
box.Prepend(new_im)
|
||||
})
|
||||
}()
|
||||
*/
|
||||
b := gtk.NewLabel(n)
|
||||
|
||||
@@ -1208,7 +1230,7 @@ func activate(app *gtk.Application) {
|
||||
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
||||
app.SetMenubar(gio.NewMenu())
|
||||
|
||||
window.SetTitle("Lambda")
|
||||
window.SetTitle(loadedLocale["appName"])
|
||||
window.Window.AddCSSClass("ssd")
|
||||
window.Window.SetDefaultSize(500, 500)
|
||||
menu = gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
|
||||
Reference in New Issue
Block a user