Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13780881
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/bots/findBots.sh b/bots/findBots.sh
index e0319b6..f27e610 100755
--- a/bots/findBots.sh
+++ b/bots/findBots.sh
@@ -1,40 +1,45 @@
#!/bin/bash
#
# Generates a Go map containing all bots that have accessed Write.as from the
# application logs stored in /var/log/
#
# usage: findBots.sh application.log
#
+if [ -z $1 ]; then
+ echo usage: findBots.sh [logfilename]
+ exit 1
+fi
+
cat /var/log/$1 | grep -i 'bot\|spider\|crawl\|scraper\|indexer\|voltron' | awk -F\" '{print $4}' | sort | uniq > bots.txt
rm bots.go
cat > bots.go << EOM
// This package helps the backend determine which clients are bots or crawlers.
// In Write.as, this is used to prevent certain things when viewing posts, like
// incrementing the view count.
package bots
var bots = map[string]bool {
EOM
while read b; do
if [ -n "$b" ]; then
echo " \"$b\": true," >> bots.go
fi
done <bots.txt
cat >> bots.go << EOM
};
// IsBot returns whether or not the provided User-Agent string is a known bot
// or crawler.
func IsBot(ua string) bool {
if _, ok := bots[ua]; ok {
return true
}
return false
}
EOM
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 30, 3:16 PM (14 m, 50 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3610840
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment