Skip to content

Commit

Permalink
Merge pull request #1144 from Andrew15-5/remove-trailing-whitespaces
Browse files Browse the repository at this point in the history
chore(wiki): removed trailing whitespaces
  • Loading branch information
gustavo-iniguez-goya authored Jun 10, 2024
2 parents 220be74 + 7373e18 commit f31f2ce
Show file tree
Hide file tree
Showing 35 changed files with 141 additions and 141 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: protocol daemon/opensnitchd ui/resources_rc.py

install:
@cd daemon && make install
@cd daemon && make install
@cd ui && make install

protocol:
Expand All @@ -26,20 +26,20 @@ run:
opensnitch-ui --socket unix:///tmp/osui.sock &
./daemon/opensnitchd -rules-path /etc/opensnitchd/rules -ui-socket unix:///tmp/osui.sock -cpu-profile cpu.profile -mem-profile mem.profile

test:
clear
test:
clear
make clean
clear
mkdir -p rules
make
make
clear
make run

adblocker:
clear
clear
make clean
clear
make
make
clear
python make_ads_rules.py
clear
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ In order to submit changes for the wiki, please follow these steps:

3. Make necessary modifications to the files located in the wiki/ directory

4. Create a pull request.
4. Create a pull request.
2 changes: 1 addition & 1 deletion daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
@systemctl daemon-reload

opensnitchd:
@go build -o opensnitchd .
@go build -o opensnitchd .

clean:
@rm -rf opensnitchd
Expand Down
2 changes: 1 addition & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ License: GPL-3.0
details.
.
You should have received a copy of the GNU General Public
License along with this program. If not, If not, see
License along with this program. If not, If not, see
http://www.gnu.org/licenses/.
.
On Debian systems, the full text of the GNU General Public
Expand Down
2 changes: 1 addition & 1 deletion proto/ui.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ message Notification {
string serverName = 3;
// CHANGE_CONFIG: 2, data: {"default_timeout": 1, ...}
Action type = 4;
string data = 5;
string data = 5;
repeated Rule rules = 6;
}

Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
CURRENT_VERSION=$(cat daemon/core/version.go | grep Version | cut -d '"' -f 2)
TO_UPDATE=(
daemon/core/version.go
ui/version.py
ui/version.py
)

echo -n "Current version is $CURRENT_VERSION, select new version: "
Expand Down
2 changes: 1 addition & 1 deletion ui/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ License: GPL-3.0
details.
.
You should have received a copy of the GNU General Public
License along with this program. If not, If not, see
License along with this program. If not, If not, see
http://www.gnu.org/licenses/.
.
On Debian systems, the full text of the GNU General Public
Expand Down
2 changes: 1 addition & 1 deletion ui/debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ License: GPL-3.0
details.
.
You should have received a copy of the GNU General Public
License along with this program. If not, If not, see
License along with this program. If not, If not, see
http://www.gnu.org/licenses/.
.
On Debian systems, the full text of the GNU General Public
Expand Down
4 changes: 2 additions & 2 deletions ui/i18n/locales/de_DE/opensnitch-de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ Knoten an</translation>
</message>
<message>
<location filename="../../../opensnitch/res/ruleseditor.ui" line="260"/>
<source>Commas or spaces are not allowed to specify multiple domains.
<source>Commas or spaces are not allowed to specify multiple domains.

Use regular expressions instead:
Use regular expressions instead:
.*(opensnitch|duckduckgo).com
.*\.google.com

Expand Down
4 changes: 2 additions & 2 deletions ui/i18n/locales/es_ES/opensnitch-es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ los nodos</translation>
</message>
<message>
<location filename="../../../opensnitch/res/ruleseditor.ui" line="260"/>
<source>Commas or spaces are not allowed to specify multiple domains.
<source>Commas or spaces are not allowed to specify multiple domains.

Use regular expressions instead:
Use regular expressions instead:
.*(opensnitch|duckduckgo).com
.*\.google.com

Expand Down
4 changes: 2 additions & 2 deletions ui/i18n/locales/eu_ES/opensnitch-eu_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,9 @@
</message>
<message>
<location filename="../../../opensnitch/res/ruleseditor.ui" line="260"/>
<source>Commas or spaces are not allowed to specify multiple domains.
<source>Commas or spaces are not allowed to specify multiple domains.

Use regular expressions instead:
Use regular expressions instead:
.*(opensnitch|duckduckgo).com
.*\.google.com

Expand Down
4 changes: 2 additions & 2 deletions ui/i18n/locales/pt_BR/opensnitch-pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@
</message>
<message>
<location filename="../../../opensnitch/res/ruleseditor.ui" line="260"/>
<source>Commas or spaces are not allowed to specify multiple domains.
<source>Commas or spaces are not allowed to specify multiple domains.

Use regular expressions instead:
Use regular expressions instead:
.*(opensnitch|duckduckgo).com
.*\.google.com

Expand Down
4 changes: 2 additions & 2 deletions ui/opensnitch-ui.spec
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fi
if [ $1 -eq 1 ]; then
echo -e "\n You need to install 2 more packages:
unicode_slugify and grpcio-tools.

pip3 install grpcio-tools
pip3 install unicode_slugify
"
Expand All @@ -83,7 +83,7 @@ if [ $1 -eq 0 ]; then
done

pkill -15 opensnitch-ui 2>/dev/null || true

echo ""
echo " Remember to uninstall grpcio-tools and unicode_slugify if you don't"
echo " need them anymore:"
Expand Down
66 changes: 33 additions & 33 deletions ui/opensnitch/customwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, parent=None, *args, config=None):
def paint(self, painter, option, index):
if not index.isValid():
return super().paint(painter, option, index)

nocolor=True

value = index.data(QtCore.Qt.DisplayRole)
Expand All @@ -41,7 +41,7 @@ class ColorizedQSqlQueryModel(QSqlQueryModel):
model=CustomQSqlQueryModel(
modelData=
{
'colorize':
'colorize':
{'offline': (QColor(QtCore.Qt.red), 2)},
'alignment': { Qt.AlignLeft, 2 }
}
Expand Down Expand Up @@ -89,16 +89,16 @@ class ConnectionsTableModel(QStandardItemModel):
db = None
#original query string before we modify it
origQueryStr = QSqlQuery()
#modified query object
#modified query object
realQuery = QSqlQuery()
#previous original query string; used to check if the query has changed
prevQueryStr = ''
#whether or not the original query has a filter (a WHERE condition)
isQueryFilter = False
limit = None

#a map for fast lookup or rows when filter is enabled
#contains ranges of rowids and count of filter hits
#contains ranges of rowids and count of filter hits
#range format {'from': <rowid>, 'to': <rowid>, 'hits':<int>}
#including the 'from' rowid up to but NOT including the 'to' rowid
map = []
Expand Down Expand Up @@ -142,7 +142,7 @@ def setQuery(self, q, db):
self.updateDistinctIfNeeded()
self.limit = int(q.split(' ')[-1]) if q.split(' ')[-2] == 'LIMIT' else None
self.isQueryFilter = True if ("LIKE '%" in q and "LIKE '% %'" not in q) or 'Action = "' in q else False

self.realQuery = QSqlQuery(db)
isTotalRowCountChanged = False
isQueryChanged = False
Expand All @@ -160,7 +160,7 @@ def setQuery(self, q, db):
self.realQuery.setForwardOnly(True)
for offset in range(0, newRowsCount, self.rangeSize):
lowerBound = largestRowIdInMap + offset
upperBound = min(lowerBound + self.rangeSize, self.maxRowId)
upperBound = min(lowerBound + self.rangeSize, self.maxRowId)
part1, part2 = q.split('ORDER')
qStr = part1 + 'AND rowid>'+ str(lowerBound) + ' AND rowid<=' + str(upperBound) + ' ORDER' + part2
self.realQuery.exec(qStr)
Expand Down Expand Up @@ -205,8 +205,8 @@ def buildMap(self):
#we only want to know the count of matching rows
qStr = "SELECT COUNT(*) from connections WHERE (rowid> :lowerBound AND rowid<= :upperBound)"
if actionStr:
qStr += ' AND ' + actionStr
matchStr = self.getMatch(filterStr) if filterStr else None
qStr += ' AND ' + actionStr
matchStr = self.getMatch(filterStr) if filterStr else None
if matchStr:
qStr += ' AND ' + matchStr
qStr += ' LIMIT ' + str(self.limit) if self.limit else ''
Expand Down Expand Up @@ -242,7 +242,7 @@ def updateDistinctIfNeeded(self, force=False):
q = QSqlQuery(self.db)
q.setForwardOnly(True)
for column in self.distinct.keys():
q.exec('SELECT DISTINCT ' + column + ' FROM connections WHERE rowid>'
q.exec('SELECT DISTINCT ' + column + ' FROM connections WHERE rowid>'
+ str(self.distinctLastRowId) + ' AND rowid<=' + str(self.maxRowId))
while q.next():
if q.value(0) not in self.distinct[column]:
Expand All @@ -267,15 +267,15 @@ def refreshViewport(self, value, maxRowsInViewport):
qStr = self.origQueryStr.split('WHERE')[0] + ' WHERE '
actionStr = self.getActionStr()
if actionStr:
qStr += actionStr + " AND "
qStr += actionStr + " AND "
#find inside the map the range(s) in which top and bottom rows are located
total, offsetInRange, botRowFound, topRowFound = 0, None, False, False
ranges = [{'from':0, 'to':0, 'hits':0}]
for i in reversed(self.map):
if total + i['hits'] >= botRowNo:
botRowFound = True
if total + i['hits'] >= topRowNo:
topRowFound = True
topRowFound = True
if botRowFound and i['hits'] > 0:
if i['to'] == ranges[-1]['from']:
#merge two adjacent ranges
Expand All @@ -296,23 +296,23 @@ def refreshViewport(self, value, maxRowsInViewport):
rangeStr = rangeStr[:-3] #remove trailing 'OR '
rangeStr += ') AND '
qStr += rangeStr

filterStr = self.getFilterStr()
matchStr = self.getMatch(filterStr) if filterStr else None
matchStr = self.getMatch(filterStr) if filterStr else None
if matchStr:
qStr += matchStr + " AND "
qStr = qStr[:-4] #remove trailing ' AND'
qStr += ' ORDER '+ self.origQueryStr.split('ORDER')[1]

q.exec(qStr)
q.last()
rowsFound = max(0, q.at()+1)
if not self.isQueryFilter:
q.seek(QSql.BeforeFirstRow)
else:
#position the db cursor on topRowNo
q.seek(QSql.BeforeFirstRow if offsetInRange == 0 else offsetInRange-1)
upperBound = min(maxRowsInViewport, rowsFound)
q.seek(QSql.BeforeFirstRow if offsetInRange == 0 else offsetInRange-1)
upperBound = min(maxRowsInViewport, rowsFound)
self.setRowCount(upperBound)
#only visible rows will be filled with data
if upperBound > 0:
Expand All @@ -324,7 +324,7 @@ def refreshViewport(self, value, maxRowsInViewport):
self.setItem(x, col, QStandardItem(q.value(col)))
self.blockSignals(False)
self.dataChanged.emit(self.createIndex(0,0), self.createIndex(upperBound, len(self.headerLabels)))

#form a condition string for the query: if filterStr is (partially) present in any of the columns
def getMatch (self, filterStr):
match = {}
Expand All @@ -335,7 +335,7 @@ def getMatch (self, filterStr):
match[column].append(value)
matchStr = None
if any([match[col] for col in match]):
matchStr = '( '
matchStr = '( '
if match['process']:
matchStr += "process IN ('" + "','".join(match['process']) + "') OR"
if match['dst_host']:
Expand Down Expand Up @@ -385,7 +385,7 @@ def dumpRows(self):
return rows

class ConnectionsTableView(QTableView):
# how many rows can potentially be displayed in viewport
# how many rows can potentially be displayed in viewport
# the actual number of rows currently displayed may be less than this
maxRowsInViewport = 0
#vertical scroll bar
Expand All @@ -400,7 +400,7 @@ def __init__(self, parent):
self.horizontalHeader().setStretchLastSection(True)
#the built-in vertical scrollBar of this view is always off
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

def setVerticalScrollBar(self, vScrollBar):
self.vScrollBar = vScrollBar
self.vScrollBar.valueChanged.connect(self.onValueChanged)
Expand All @@ -418,7 +418,7 @@ def setModel(self, model):
#stretch the bottom row; we don't want partial-height rows at the bottom
#this will only trigger if rowCount value was changed
def onRowsInsertedOrRemoved(self, parent, start, end):
if self.model().rowCount() == self.maxRowsInViewport:
if self.model().rowCount() == self.maxRowsInViewport:
self.verticalHeader().setStretchLastSection(True)
else:
self.verticalHeader().setStretchLastSection(False)
Expand All @@ -428,7 +428,7 @@ def resizeEvent(self, event):
#refresh the viewport data based on new geometry
self.calculateRowsInViewport()
self.model().setRowCount(min(self.maxRowsInViewport, self.model().totalRowCount))
self.model().refreshViewport(self.vScrollBar.value(), self.maxRowsInViewport)
self.model().refreshViewport(self.vScrollBar.value(), self.maxRowsInViewport)

def calculateRowsInViewport(self):
rowHeight = self.verticalHeader().defaultSectionSize()
Expand All @@ -437,14 +437,14 @@ def calculateRowsInViewport(self):

def onValueChanged(self, vSBNewValue):
savedIndex = self.selectionModel().currentIndex()
self.model().refreshViewport(vSBNewValue, self.maxRowsInViewport)
#restore selection which was removed by model's refreshing the data
self.model().refreshViewport(vSBNewValue, self.maxRowsInViewport)
#restore selection which was removed by model's refreshing the data
self.selectionModel().setCurrentIndex(savedIndex, QItemSelectionModel.Rows | QItemSelectionModel.SelectCurrent)

# if ( scrollbar at the top or row limit set):
# let new rows "push down" older rows without changing the scrollbar position
# else:
# don't update data in viewport, only change scrollbar position.
# don't update data in viewport, only change scrollbar position.
def onRowCountChanged(self):
totalCount = self.model().totalRowCount
scrollBar = self.vScrollBar
Expand All @@ -455,16 +455,16 @@ def onRowCountChanged(self):
scrollBar.setMinimum(0)
scrollBar.setMaximum( min(totalCount, self.model().limit) - self.maxRowsInViewport)
if scrollBarValue != newValue:
#setValue does not trigger valueChanged if new value is the same as old
#setValue does not trigger valueChanged if new value is the same as old
scrollBar.setValue(newValue)
else:
scrollBar.valueChanged.emit(newValue)
scrollBar.valueChanged.emit(newValue)
else:
scrollBar.setMinimum(0)
scrollBar.setMinimum(0)
scrollBar.setMaximum(max(0, totalCount - self.maxRowsInViewport))
if scrollBarValue == 0:
scrollBar.valueChanged.emit(0)
elif scrollBarValue > 0:
scrollBar.valueChanged.emit(0)
elif scrollBarValue > 0:
if self.model().prependedRowCount == 0:
scrollBar.valueChanged.emit(scrollBarValue)
else:
Expand All @@ -480,11 +480,11 @@ def onKeyDown(self):

def onKeyHome(self):
self.vScrollBar.setValue(0)
self.selectionModel().setCurrentIndex(self.model().createIndex(0, 0), QItemSelectionModel.Rows | QItemSelectionModel.SelectCurrent)
self.selectionModel().setCurrentIndex(self.model().createIndex(0, 0), QItemSelectionModel.Rows | QItemSelectionModel.SelectCurrent)

def onKeyEnd(self):
self.vScrollBar.setValue(self.vScrollBar.maximum())
self.selectionModel().setCurrentIndex(self.model().createIndex(min(self.maxRowsInViewport, self.model().totalRowCount) - 1, 0), QItemSelectionModel.Rows | QItemSelectionModel.SelectCurrent)
self.selectionModel().setCurrentIndex(self.model().createIndex(min(self.maxRowsInViewport, self.model().totalRowCount) - 1, 0), QItemSelectionModel.Rows | QItemSelectionModel.SelectCurrent)

def onKeyPageUp(self):
#scroll up only when on the first row
Expand Down
Loading

0 comments on commit f31f2ce

Please sign in to comment.