Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 543d42f

Browse files
authored
Suppress licensing module (#1530)
<!-- A note on testing your PR --> <!-- Basic unit test run is executed against each commit in the PR. If you want to run a full integration test suite, you can trigger it by commenting with '/run-integration-tests' or '/run-it' -->
1 parent bf70a5a commit 543d42f

File tree

5 files changed

+105
-111
lines changed

5 files changed

+105
-111
lines changed

cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ func main() {
7070
log.Fatalf("error validating configuration: %v", err)
7171
}
7272

73-
licenseMod := licensing.Init(&cfg)
73+
_ = licensing.Init(&cfg)
7474
qmcLogChannel := logger.InitLogger(logger.Configuration{
7575
FileLogging: cfg.Logging.FileLogging,
7676
Path: cfg.Logging.Path,
7777
RemoteLogDrainUrl: cfg.Logging.RemoteLogDrainUrl.ToUrl(),
7878
Level: *cfg.Logging.Level,
79-
ClientId: licenseMod.License.ClientID,
79+
ClientId: "",
8080
}, sig, doneCh)
8181
defer logger.StdLogFile.Close()
8282
defer logger.ErrLogFile.Close()
@@ -89,7 +89,7 @@ func main() {
8989
var connectionPool = clickhouse.InitDBConnectionPool(&cfg)
9090
//var connectionPool = doris.InitDBConnectionPool(&cfg)
9191

92-
phoneHomeAgent := telemetry.NewPhoneHomeAgent(&cfg, connectionPool, licenseMod.License.ClientID)
92+
phoneHomeAgent := telemetry.NewPhoneHomeAgent(&cfg, connectionPool, "")
9393
phoneHomeAgent.Start()
9494

9595
virtualTableStorage := persistence.NewElasticJSONDatabase(cfg.Elasticsearch, common_table.VirtualTableElasticIndexName)

platform/connectors/connector.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
package connectors
44

55
import (
6-
"fmt"
76
"github.com/QuesmaOrg/quesma/platform/config"
87
"github.com/QuesmaOrg/quesma/platform/database_common"
9-
"github.com/QuesmaOrg/quesma/platform/licensing"
108
"github.com/QuesmaOrg/quesma/platform/logger"
119
"github.com/QuesmaOrg/quesma/platform/telemetry"
1210
quesma_api "github.com/QuesmaOrg/quesma/platform/v2/core"
@@ -27,14 +25,14 @@ func (c *ConnectorManager) GetConnector() *database_common.LogManager {
2725
if len(c.connectors) == 0 {
2826
panic("No connectors found")
2927
}
30-
conn := c.connectors[0]
31-
if !c.connectors[0].GetConnector().IsInTransparentProxyMode() {
32-
go func() {
33-
if err := conn.LicensingCheck(); err != nil {
34-
licensing.PanicWithLicenseViolation(fmt.Errorf("connector [%s] reported licensing issue: [%v]", conn.Type(), err))
35-
}
36-
}()
37-
}
28+
//conn := c.connectors[0]
29+
//if !c.connectors[0].GetConnector().IsInTransparentProxyMode() {
30+
// go func() {
31+
// if err := conn.LicensingCheck(); err != nil {
32+
// licensing.PanicWithLicenseViolation(fmt.Errorf("connector [%s] reported licensing issue: [%v]", conn.Type(), err))
33+
// }
34+
// }()
35+
//}
3836
return c.connectors[0].GetConnector()
3937
}
4038

platform/licensing/license_manager.go

Lines changed: 66 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33
package licensing
44

55
import (
6-
"bytes"
76
"fmt"
8-
"github.com/goccy/go-json"
9-
"io"
10-
"net/http"
11-
"time"
127
)
138

14-
const (
15-
obtainLicenseEndpoint = "https://licensing.quesma.com/api/license/obtain"
16-
verifyLicenseEndpoint = "https://licensing.quesma.com/api/license/verify"
17-
)
9+
//const (
10+
// obtainLicenseEndpoint = "https://licensing.quesma.com/api/license/obtain"
11+
// verifyLicenseEndpoint = "https://licensing.quesma.com/api/license/verify"
12+
//)
1813

1914
type InstallationIDPayload struct {
2015
InstallationID string `json:"installation_id"`
@@ -25,31 +20,31 @@ type LicensePayload struct {
2520
}
2621

2722
// obtainLicenseKey presents an InstallationId to the license server and receives a LicenseKey in return
28-
func (l *LicenseModule) obtainLicenseKey() (err error) {
29-
l.logDebug("Obtaining license key for installation ID [%s]", l.InstallationID)
30-
var payloadBytes []byte
31-
if payloadBytes, err = json.Marshal(InstallationIDPayload{InstallationID: l.InstallationID}); err != nil {
32-
return err
33-
}
34-
resp, err := http.Post(obtainLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
35-
if err != nil {
36-
return err
37-
}
38-
defer resp.Body.Close()
39-
40-
body, err := io.ReadAll(resp.Body)
41-
if err != nil {
42-
return err
43-
}
44-
45-
var licenseResponse LicensePayload
46-
if err = json.Unmarshal(body, &licenseResponse); err != nil {
47-
return err
48-
}
49-
l.LicenseKey = []byte(licenseResponse.LicenseKey)
50-
fmt.Printf("License key obtained and set successfully, key=[%s.....%s]\n", string(l.LicenseKey[:8]), string(l.LicenseKey[len(l.LicenseKey)-8:]))
51-
return nil
52-
}
23+
//func (l *LicenseModule) obtainLicenseKey() (err error) {
24+
// l.logDebug("Obtaining license key for installation ID [%s]", l.InstallationID)
25+
// var payloadBytes []byte
26+
// if payloadBytes, err = json.Marshal(InstallationIDPayload{InstallationID: l.InstallationID}); err != nil {
27+
// return err
28+
// }
29+
// resp, err := http.Post(obtainLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
30+
// if err != nil {
31+
// return err
32+
// }
33+
// defer resp.Body.Close()
34+
//
35+
// body, err := io.ReadAll(resp.Body)
36+
// if err != nil {
37+
// return err
38+
// }
39+
//
40+
// var licenseResponse LicensePayload
41+
// if err = json.Unmarshal(body, &licenseResponse); err != nil {
42+
// return err
43+
// }
44+
// l.LicenseKey = []byte(licenseResponse.LicenseKey)
45+
// fmt.Printf("License key obtained and set successfully, key=[%s.....%s]\n", string(l.LicenseKey[:8]), string(l.LicenseKey[len(l.LicenseKey)-8:]))
46+
// return nil
47+
//}
5348

5449
func FormatLicenseKey(licenseKey []byte) string {
5550
if len(licenseKey) < 8 { // too short to be obfuscated, most probably it's invalid anyway
@@ -59,41 +54,41 @@ func FormatLicenseKey(licenseKey []byte) string {
5954
}
6055

6156
// processLicense presents the license to the license server and receives an AllowList in return
62-
func (l *LicenseModule) processLicense() error {
63-
if fetchedLicense, err := l.fetchLicense(); err != nil {
64-
return fmt.Errorf("license validation failed with: %v", err)
65-
} else {
66-
l.License = fetchedLicense
67-
l.logDebug("Allowlist loaded successfully")
68-
l.logDebug("%s", fetchedLicense.String())
69-
}
70-
if l.License.ExpirationDate.Before(time.Now()) {
71-
return fmt.Errorf("license expired on %s", l.License.ExpirationDate)
72-
}
73-
return nil
74-
}
57+
//func (l *LicenseModule) processLicense() error {
58+
// if fetchedLicense, err := l.fetchLicense(); err != nil {
59+
// return fmt.Errorf("license validation failed with: %v", err)
60+
// } else {
61+
// l.License = fetchedLicense
62+
// l.logDebug("Allowlist loaded successfully")
63+
// l.logDebug("%s", fetchedLicense.String())
64+
// }
65+
// if l.License.ExpirationDate.Before(time.Now()) {
66+
// return fmt.Errorf("license expired on %s", l.License.ExpirationDate)
67+
// }
68+
// return nil
69+
//}
7570

76-
func (l *LicenseModule) fetchLicense() (a *License, err error) {
77-
var payloadBytes []byte
78-
if payloadBytes, err = json.Marshal(LicensePayload{LicenseKey: string(l.LicenseKey)}); err != nil {
79-
return nil, err
80-
}
81-
resp, err := http.Post(verifyLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
82-
if resp.StatusCode == http.StatusUnauthorized {
83-
return nil, fmt.Errorf("license key rejected by the License server")
84-
}
85-
if err != nil {
86-
return nil, err
87-
}
88-
defer resp.Body.Close()
89-
body, err := io.ReadAll(resp.Body)
90-
if err != nil {
91-
return nil, err
92-
}
93-
94-
if err = json.Unmarshal(body, &a); err != nil {
95-
return nil, err
96-
} else {
97-
return a, nil
98-
}
99-
}
71+
//func (l *LicenseModule) fetchLicense() (a *License, err error) {
72+
// var payloadBytes []byte
73+
// if payloadBytes, err = json.Marshal(LicensePayload{LicenseKey: string(l.LicenseKey)}); err != nil {
74+
// return nil, err
75+
// }
76+
// resp, err := http.Post(verifyLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
77+
// if resp.StatusCode == http.StatusUnauthorized {
78+
// return nil, fmt.Errorf("license key rejected by the License server")
79+
// }
80+
// if err != nil {
81+
// return nil, err
82+
// }
83+
// defer resp.Body.Close()
84+
// body, err := io.ReadAll(resp.Body)
85+
// if err != nil {
86+
// return nil, err
87+
// }
88+
//
89+
// if err = json.Unmarshal(body, &a); err != nil {
90+
// return nil, err
91+
// } else {
92+
// return a, nil
93+
// }
94+
//}

platform/licensing/model.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010

1111
// License is an object returned by the license server based on the provided (and positively verified) license key
1212
type License struct {
13-
InstallationID string `json:"installation_id"`
14-
ClientID string `json:"client_id"`
13+
InstallationID string `json:"installation_id"`
14+
// Deprecated
15+
ClientID string `json:"client_id"` // used to be a human-readable organization name for telemetry purposes, given licensing module disabling its now irrelevant
1516
Connectors []string `json:"connectors"`
1617
Processors []string `json:"processors"`
1718
ExpirationDate time.Time `json:"expiration_date"`

platform/licensing/runner.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import (
1010
"github.com/google/uuid"
1111
"github.com/rs/zerolog"
1212
"os"
13-
"slices"
1413
)
1514

1615
type LicenseModule struct {
1716
InstallationID string
1817
LicenseKey []byte
19-
License *License
20-
Config *config.QuesmaConfiguration
18+
//Deprecated
19+
License *License // License module has been disabled
20+
Config *config.QuesmaConfiguration
2121
}
2222

2323
const (
@@ -66,31 +66,31 @@ func (l *LicenseModule) Run() {
6666
} else {
6767
l.logInfo("License key not supplied in the configuration, will attempt to obtain temporary license with limited functionalities")
6868
l.setInstallationID()
69-
if err := l.obtainLicenseKey(); err != nil {
70-
PanicWithLicenseViolation(fmt.Errorf("failed to obtain license key: %v", err))
71-
}
72-
}
73-
if err := l.processLicense(); err != nil {
74-
PanicWithLicenseViolation(fmt.Errorf("failed to process license: %v", err))
75-
}
76-
if err := l.validateConfig(); err != nil {
77-
PanicWithLicenseViolation(fmt.Errorf("failed to validate configuration: %v", err))
69+
//if err := l.obtainLicenseKey(); err != nil {
70+
// PanicWithLicenseViolation(fmt.Errorf("failed to obtain license key: %v", err))
71+
//}
7872
}
73+
//if err := l.processLicense(); err != nil {
74+
// PanicWithLicenseViolation(fmt.Errorf("failed to process license: %v", err))
75+
//}
76+
//if err := l.validateConfig(); err != nil {
77+
// PanicWithLicenseViolation(fmt.Errorf("failed to validate configuration: %v", err))
78+
//}
7979
}
8080

81-
func (l *LicenseModule) validateConfig() error {
82-
// Check if connectors are allowed
83-
for _, conn := range l.Config.Connectors {
84-
// TODO remove this once hydrolix connector is fully integrated
85-
if conn.ConnectorType == "hydrolix" {
86-
continue
87-
}
88-
if !slices.Contains(l.License.Connectors, conn.ConnectorType) {
89-
return fmt.Errorf("connector of type [%s] is not allowed within the current license", conn.ConnectorType)
90-
}
91-
}
92-
return nil
93-
}
81+
//func (l *LicenseModule) validateConfig() error {
82+
// // Check if connectors are allowed
83+
// for _, conn := range l.Config.Connectors {
84+
// // TODO remove this once hydrolix connector is fully integrated
85+
// if conn.ConnectorType == "hydrolix" {
86+
// continue
87+
// }
88+
// if !slices.Contains(l.License.Connectors, conn.ConnectorType) {
89+
// return fmt.Errorf("connector of type [%s] is not allowed within the current license", conn.ConnectorType)
90+
// }
91+
// }
92+
// return nil
93+
//}
9494

9595
func (l *LicenseModule) setInstallationID() {
9696
if l.Config.InstallationId != "" {

0 commit comments

Comments
 (0)